Skip to content

Commit 2744067

Browse files
author
Ary Borenszweig
committedMar 23, 2017
Fixed #4145: Formatter: Crash when double splats has restrictions in some cases
1 parent 3f183a6 commit 2744067

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed
 

Diff for: ‎spec/compiler/formatter/formatter_spec.cr

+2
Original file line numberDiff line numberDiff line change
@@ -1015,4 +1015,6 @@ describe Crystal::Formatter do
10151015
assert_format "def a\n b(\n 1, # x\n # y\n 2\n )\nend"
10161016
assert_format "def a\n b(\n a: 1, # x\n # y\n b: 2\n )\nend"
10171017
assert_format "def a\n b(\n 1, # x\n # y\n a: 1, # x\n # y\n b: 2 # z\n )\nend"
1018+
1019+
assert_format "def foo(a, **b : Int32)\nend"
10181020
end

Diff for: ‎src/compiler/crystal/tools/formatter.cr

+2-4
Original file line numberDiff line numberDiff line change
@@ -1477,10 +1477,8 @@ module Crystal
14771477
comma_written = true
14781478
end
14791479
write_token :"**"
1480-
skip_space
1481-
check :IDENT
1482-
write double_splat
1483-
next_token_skip_space
1480+
double_splat.accept self
1481+
skip_space_or_newline
14841482
if block_arg
14851483
check :","
14861484
write ","

0 commit comments

Comments
 (0)
Please sign in to comment.