Skip to content

Commit

Permalink
Parser: fix parsing of do inside yield. Fixes #4526
Browse files Browse the repository at this point in the history
  • Loading branch information
asterite committed Jun 7, 2017
1 parent bbf79fb commit b7e9237
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions spec/compiler/parser/parser_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -1274,6 +1274,8 @@ describe "Parser" do
it_parses "1 rescue 2 if 3", If.new(3.int32, ExceptionHandler.new(1.int32, [Rescue.new(2.int32)]))
it_parses "1 ensure 2 if 3", If.new(3.int32, ExceptionHandler.new(1.int32, ensure: 2.int32))

it_parses "yield foo do\nend", Yield.new([Call.new(nil, "foo", block: Block.new)] of ASTNode)

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

%w(def macro class struct module fun alias abstract include extend lib).each do |keyword|
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/crystal/syntax/parser.cr
Original file line number Diff line number Diff line change
Expand Up @@ -4737,7 +4737,7 @@ module Crystal
end_location = token_end_location
next_token

call_args = preserve_stop_on_do { parse_call_args }
call_args = preserve_stop_on_do { parse_call_args control: true }

if call_args
args = call_args.args
Expand Down

0 comments on commit b7e9237

Please sign in to comment.