Skip to content

Commit

Permalink
Fixed #4145: Formatter: Crash when double splats has restrictions in …
Browse files Browse the repository at this point in the history
…some cases
  • Loading branch information
asterite committed Mar 23, 2017
1 parent 3f183a6 commit 2744067
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 2 additions & 0 deletions spec/compiler/formatter/formatter_spec.cr
Expand Up @@ -1015,4 +1015,6 @@ describe Crystal::Formatter do
assert_format "def a\n b(\n 1, # x\n # y\n 2\n )\nend"
assert_format "def a\n b(\n a: 1, # x\n # y\n b: 2\n )\nend"
assert_format "def a\n b(\n 1, # x\n # y\n a: 1, # x\n # y\n b: 2 # z\n )\nend"

assert_format "def foo(a, **b : Int32)\nend"
end
6 changes: 2 additions & 4 deletions src/compiler/crystal/tools/formatter.cr
Expand Up @@ -1477,10 +1477,8 @@ module Crystal
comma_written = true
end
write_token :"**"
skip_space
check :IDENT
write double_splat
next_token_skip_space
double_splat.accept self
skip_space_or_newline
if block_arg
check :","
write ","
Expand Down

0 comments on commit 2744067

Please sign in to comment.