Skip to content

Commit

Permalink
Parser: correct to parse 'foo &.%(1)' (#4664)
Browse files Browse the repository at this point in the history
Fix #4662
  • Loading branch information
makenowjust authored and RX14 committed Sep 7, 2017
1 parent 19bb517 commit 3fbdde5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions spec/compiler/parser/parser_spec.cr
Expand Up @@ -305,6 +305,7 @@ describe "Parser" do
it_parses "foo(&.block)", Call.new(nil, "foo", block: Block.new([Var.new("__arg0")], Call.new(Var.new("__arg0"), "block")))
it_parses "foo &.block", Call.new(nil, "foo", block: Block.new([Var.new("__arg0")], Call.new(Var.new("__arg0"), "block")))
it_parses "foo &./(1)", Call.new(nil, "foo", block: Block.new([Var.new("__arg0")], Call.new(Var.new("__arg0"), "/", 1.int32)))
it_parses "foo &.%(1)", Call.new(nil, "foo", block: Block.new([Var.new("__arg0")], Call.new(Var.new("__arg0"), "%", 1.int32)))
it_parses "foo &.block(1)", Call.new(nil, "foo", block: Block.new([Var.new("__arg0")], Call.new(Var.new("__arg0"), "block", 1.int32)))
it_parses "foo &.+(2)", Call.new(nil, "foo", block: Block.new([Var.new("__arg0")], Call.new(Var.new("__arg0"), "+", 2.int32)))
it_parses "foo &.bar.baz", Call.new(nil, "foo", block: Block.new([Var.new("__arg0")], Call.new(Call.new(Var.new("__arg0"), "bar"), "baz")))
Expand Down
10 changes: 9 additions & 1 deletion src/compiler/crystal/syntax/parser.cr
Expand Up @@ -1376,8 +1376,16 @@ module Crystal
@block_arg_count += 1

obj = Var.new(block_arg_name)

@wants_regex = false
next_token_skip_space
if current_char == '%'
next_char
@token.type = :"%"
@token.column_number += 1
skip_space
else
next_token_skip_space
end

location = @token.location

Expand Down

0 comments on commit 3fbdde5

Please sign in to comment.