Skip to content

Commit 2f2c04f

Browse files
makenowjustRX14
authored andcommittedApr 21, 2018
Don't parse NamedTuple type without comma seperator (#5981)
Fixed #5979
1 parent 32f46c1 commit 2f2c04f

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed
 

Diff for: ‎spec/compiler/parser/parser_spec.cr

+1
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,7 @@ describe "Parser" do
500500
it_parses "Foo(x: U)", Generic.new("Foo".path, [] of ASTNode, named_args: [NamedArgument.new("x", "U".path)])
501501
it_parses "Foo(x: U, y: V)", Generic.new("Foo".path, [] of ASTNode, named_args: [NamedArgument.new("x", "U".path), NamedArgument.new("y", "V".path)])
502502
assert_syntax_error "Foo(T, x: U)"
503+
assert_syntax_error "Foo(x: T y: U)"
503504

504505
it_parses %(Foo("foo bar": U)), Generic.new("Foo".path, [] of ASTNode, named_args: [NamedArgument.new("foo bar", "U".path)])
505506
it_parses %(Foo("foo": U, "bar": V)), Generic.new("Foo".path, [] of ASTNode, named_args: [NamedArgument.new("foo", "U".path), NamedArgument.new("bar", "V".path)])

Diff for: ‎src/compiler/crystal/syntax/parser.cr

+2-3
Original file line numberDiff line numberDiff line change
@@ -4466,9 +4466,8 @@ module Crystal
44664466
skip_space_or_newline
44674467

44684468
named_args << NamedArgument.new(name, type)
4469-
if @token.type == :","
4470-
next_token_skip_space_or_newline
4471-
end
4469+
break unless @token.type == :","
4470+
next_token_skip_space_or_newline
44724471
end
44734472

44744473
named_args

0 commit comments

Comments
 (0)
Please sign in to comment.