Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[PRISM] Fix block param instructions when it has a recevier
In the following code: ```ruby def foo(&blk) blk.call end ``` Prism was using the `getblockparam` instruction but it should be `getblockparamproxy`. In this case we have a receiver, if it's a local variable read node, then it needs to go through the path to use `getblockparamproxy`. Before: ``` == disasm: #<ISeq:<main>@test2.rb:1 (1,0)-(3,3)> 0000 definemethod :foo, foo ( 1)[Li] 0003 putobject :foo 0005 leave == disasm: #<ISeq:foo@test2.rb:1 (1,0)-(3,3)> local table (size: 1, argc: 0 [opts: 0, rest: -1, post: 0, block: 0, kw: -1@-1, kwrest: -1]) [ 1] blk@0<Block> 0000 getblockparam blk@0, 0 ( 2)[LiCa] 0003 opt_send_without_block <calldata!mid:call, argc:0, ARGS_SIMPLE> 0005 leave ( 3)[Re] ``` After: ``` == disasm: #<ISeq:<main>@test2.rb:1 (1,0)-(3,3)> 0000 definemethod :foo, foo ( 1)[Li] 0003 putobject :foo 0005 leave == disasm: #<ISeq:foo@test2.rb:1 (1,0)-(3,3)> local table (size: 1, argc: 0 [opts: 0, rest: -1, post: 0, block: 0, kw: -1@-1, kwrest: -1]) [ 1] blk@0<Block> 0000 getblockparamproxy blk@0, 0 ( 2)[LiCa] 0003 opt_send_without_block <calldata!mid:call, argc:0, ARGS_SIMPLE> 0005 leave ( 3)[Re] ``` Fixes `test_getblockparamproxy` and `test_ifunc_getblockparamproxy` in test_yjit.rb. Related to ruby/prism#2935.
- Loading branch information