Skip to content

Commit e1cdde8

Browse files
olbatAry Borenszweig
authored and
Ary Borenszweig
committedMar 3, 2017
Fix: incorrect to_s for Attribute AST node #4098
Commas are missing in the result of the `to_s` method of Attribute nodes so the output is invalid (i.e. `@[Foo(a: 1b: 2)]`).
1 parent 3dc743d commit e1cdde8

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed
 

‎spec/compiler/parser/to_s_spec.cr

+1
Original file line numberDiff line numberDiff line change
@@ -95,4 +95,5 @@ describe "ASTNode#to_s" do
9595
expect_to_s "# doc\ndef foo\nend", emit_doc: true
9696
expect_to_s "foo[x, y, a: 1, b: 2]"
9797
expect_to_s "foo[x, y, a: 1, b: 2] = z"
98+
expect_to_s %(@[Foo(1, 2, a: 1, b: 2)])
9899
end

‎src/compiler/crystal/syntax/to_s.cr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1414,8 +1414,8 @@ module Crystal
14141414
printed_arg = true
14151415
end
14161416
if named_args = node.named_args
1417-
@str << ", " if printed_arg
14181417
named_args.each do |named_arg|
1418+
@str << ", " if printed_arg
14191419
visit_named_arg_name(named_arg.name)
14201420
@str << ": "
14211421
named_arg.value.accept self

0 commit comments

Comments
 (0)
Please sign in to comment.