From 535a9b86fa9097ab87d149918dcc8f55e155e52a Mon Sep 17 00:00:00 2001 From: Ilya Bylich Date: Thu, 28 Dec 2023 13:59:27 +0100 Subject: [PATCH] + ruby33.y: parse qualified const with brace block as a method call (#970) --- lib/parser/ruby33.y | 8 ++++++++ test/test_parser.rb | 14 ++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/lib/parser/ruby33.y b/lib/parser/ruby33.y index c27d9b406..dab33da2a 100644 --- a/lib/parser/ruby33.y +++ b/lib/parser/ruby33.y @@ -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], diff --git a/test/test_parser.rb b/test/test_parser.rb index c64e93508..9d4a209ac 100644 --- a/test/test_parser.rb +++ b/test/test_parser.rb @@ -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