Skip to content

Commit

Permalink
+ ruby33.y: parse qualified const with brace block as a method call (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
iliabylich committed Dec 28, 2023
1 parent 5645dc8 commit 535a9b8
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/parser/ruby33.y
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,14 @@ rule
result = @builder.block(method_call,
begin_t, args, body, end_t)
}
| primary_value tCOLON2 tCONSTANT tLCURLY brace_body tRCURLY
{
method_call = @builder.call_method(val[0], val[1], val[2],
nil, [], nil)

args, body = val[4]
result = @builder.block(method_call, val[3], args, body, val[5])
}
| kSUPER command_args
{
result = @builder.keyword_cmd(:super, val[0],
Expand Down
14 changes: 14 additions & 0 deletions test/test_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11308,4 +11308,18 @@ def test_argument_forwarding_with_anon_rest_kwrest_and_block
%q{},
SINCE_3_2)
end

def test_ruby_bug_18878
assert_parses(
s(:block,
s(:send,
s(:const, nil, :Foo), :Bar),
s(:args,
s(:procarg0,
s(:arg, :a))),
s(:int, 42)),
'Foo::Bar { |a| 42 }',
%q{},
SINCE_3_3)
end
end

0 comments on commit 535a9b8

Please sign in to comment.