Skip to content

Commit

Permalink
Compiler: fixed parse error with block followed by division. Fixes #3359
Browse files Browse the repository at this point in the history
Ary Borenszweig committed Sep 27, 2016

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent df63f69 commit cce3e71
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions spec/compiler/parser/parser_spec.cr
Original file line number Diff line number Diff line change
@@ -1241,6 +1241,7 @@ describe "Parser" do
] of ASTNode)

it_parses "{1 => 2 / 3}", HashLiteral.new([HashLiteral::Entry.new(1.int32, Call.new(2.int32, "/", 3.int32))])
it_parses "a { |x| x } / b", Call.new(Call.new(nil, "a", block: Block.new(args: ["x".var], body: "x".var)), "/", "b".call)

assert_syntax_error "return do\nend", "unexpected token: do"

1 change: 1 addition & 0 deletions src/compiler/crystal/syntax/parser.cr
Original file line number Diff line number Diff line change
@@ -3939,6 +3939,7 @@ module Crystal
yield

end_location = token_end_location
slash_is_not_regex!
next_token_skip_space

Block.new(block_args, block_body, splat_index).at(location).at_end(end_location)

0 comments on commit cce3e71

Please sign in to comment.