Skip to content

Commit

Permalink
Fix: incorrect to_s for Attribute AST node #4098
Browse files Browse the repository at this point in the history
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)]`).
  • Loading branch information
olbat authored and Ary Borenszweig committed Mar 3, 2017
1 parent 3dc743d commit e1cdde8
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions spec/compiler/parser/to_s_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,5 @@ describe "ASTNode#to_s" do
expect_to_s "# doc\ndef foo\nend", emit_doc: true
expect_to_s "foo[x, y, a: 1, b: 2]"
expect_to_s "foo[x, y, a: 1, b: 2] = z"
expect_to_s %(@[Foo(1, 2, a: 1, b: 2)])
end
2 changes: 1 addition & 1 deletion src/compiler/crystal/syntax/to_s.cr
Original file line number Diff line number Diff line change
Expand Up @@ -1414,8 +1414,8 @@ module Crystal
printed_arg = true
end
if named_args = node.named_args
@str << ", " if printed_arg
named_args.each do |named_arg|
@str << ", " if printed_arg
visit_named_arg_name(named_arg.name)
@str << ": "
named_arg.value.accept self
Expand Down

0 comments on commit e1cdde8

Please sign in to comment.