Skip to content

Commit

Permalink
Don't parse NamedTuple type without comma seperator (#5981)
Browse files Browse the repository at this point in the history
Fixed #5979
  • Loading branch information
makenowjust authored and RX14 committed Apr 21, 2018
1 parent 32f46c1 commit 2f2c04f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
1 change: 1 addition & 0 deletions spec/compiler/parser/parser_spec.cr
Expand Up @@ -500,6 +500,7 @@ describe "Parser" do
it_parses "Foo(x: U)", Generic.new("Foo".path, [] of ASTNode, named_args: [NamedArgument.new("x", "U".path)])
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)])
assert_syntax_error "Foo(T, x: U)"
assert_syntax_error "Foo(x: T y: U)"

it_parses %(Foo("foo bar": U)), Generic.new("Foo".path, [] of ASTNode, named_args: [NamedArgument.new("foo bar", "U".path)])
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)])
Expand Down
5 changes: 2 additions & 3 deletions src/compiler/crystal/syntax/parser.cr
Expand Up @@ -4466,9 +4466,8 @@ module Crystal
skip_space_or_newline

named_args << NamedArgument.new(name, type)
if @token.type == :","
next_token_skip_space_or_newline
end
break unless @token.type == :","
next_token_skip_space_or_newline
end

named_args
Expand Down

0 comments on commit 2f2c04f

Please sign in to comment.