Skip to content

Commit b7e9237

Browse files
committedJun 7, 2017
Parser: fix parsing of do inside yield. Fixes #4526
1 parent bbf79fb commit b7e9237

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed
 

‎spec/compiler/parser/parser_spec.cr

+2
Original file line numberDiff line numberDiff line change
@@ -1274,6 +1274,8 @@ describe "Parser" do
12741274
it_parses "1 rescue 2 if 3", If.new(3.int32, ExceptionHandler.new(1.int32, [Rescue.new(2.int32)]))
12751275
it_parses "1 ensure 2 if 3", If.new(3.int32, ExceptionHandler.new(1.int32, ensure: 2.int32))
12761276

1277+
it_parses "yield foo do\nend", Yield.new([Call.new(nil, "foo", block: Block.new)] of ASTNode)
1278+
12771279
assert_syntax_error "return do\nend", "unexpected token: do"
12781280

12791281
%w(def macro class struct module fun alias abstract include extend lib).each do |keyword|

‎src/compiler/crystal/syntax/parser.cr

+1-1
Original file line numberDiff line numberDiff line change
@@ -4737,7 +4737,7 @@ module Crystal
47374737
end_location = token_end_location
47384738
next_token
47394739

4740-
call_args = preserve_stop_on_do { parse_call_args }
4740+
call_args = preserve_stop_on_do { parse_call_args control: true }
47414741

47424742
if call_args
47434743
args = call_args.args

0 commit comments

Comments
 (0)
Please sign in to comment.