Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions spec/compiler/formatter/formatter_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -2857,6 +2857,14 @@ describe Crystal::Formatter do
def baz; end
CRYSTAL

# 15180
assert_format <<-CRYSTAL
x = uninitialized Foo
{% begin %}
x = foo(x)
{% end %}
CRYSTAL

# CVE-2021-42574
describe "Unicode bi-directional control characters" do
['\u202A', '\u202B', '\u202C', '\u202D', '\u202E', '\u2066', '\u2067', '\u2068', '\u2069'].each do |char|
Expand Down
6 changes: 5 additions & 1 deletion src/compiler/crystal/tools/formatter.cr
Original file line number Diff line number Diff line change
Expand Up @@ -3657,7 +3657,11 @@ module Crystal
end

def visit(node : UninitializedVar)
accept node.var
var = node.var

@vars.last.add var.name if var.is_a?(Var)

accept var
skip_space_or_newline
write_token " ", :OP_EQ, " "
skip_space_or_newline
Expand Down
Loading