diff options
| -rw-r--r-- | prism_compile.c | 4 | ||||
| -rw-r--r-- | test/ruby/test_compile_prism.rb | 11 |
2 files changed, 12 insertions, 3 deletions
diff --git a/prism_compile.c b/prism_compile.c index 90c70849fb..bad18f0692 100644 --- a/prism_compile.c +++ b/prism_compile.c @@ -6641,8 +6641,8 @@ pm_compile_node(rb_iseq_t *iseq, const pm_node_t *node, LINK_ANCHOR *const ret, body->param.block_start = local_index; body->param.flags.has_block = true; - local = idAnd; - local_table_for_iseq->ids[local_index] = local; + local_table_for_iseq->ids[local_index] = PM_CONSTANT_AND; + st_insert(index_lookup_table, PM_CONSTANT_AND, local_index); local_index++; local = idDot3; diff --git a/test/ruby/test_compile_prism.rb b/test/ruby/test_compile_prism.rb index bcbd5449e0..b7aa75a5b0 100644 --- a/test/ruby/test_compile_prism.rb +++ b/test/ruby/test_compile_prism.rb @@ -1725,7 +1725,7 @@ end def test_BlockArgumentNode assert_prism_eval("1.then(&:to_s)") - # Test forwarding with no name + # Test anonymous block forwarding assert_prism_eval(<<~RUBY) o = Object.new def o.foo(&) = yield @@ -1733,6 +1733,15 @@ end o.bar { :ok } RUBY + + # Test anonymous block forwarding from argument forwarding + assert_prism_eval(<<~RUBY) + o = Object.new + def o.foo = yield + def o.bar(...) = foo(&) + + o.bar { :ok } + RUBY end def test_BlockLocalVariableNode |
