diff options
author | eileencodes <eileencodes@gmail.com> | 2024-07-23 14:44:46 -0400 |
---|---|---|
committer | Kevin Newton <kddnewton@gmail.com> | 2024-07-23 21:45:48 -0400 |
commit | b4a02502c2125cebd034967027d65ee975987f73 (patch) | |
tree | d8bddd976d86f412ce3a63a1db42384aa3cca516 /lib/bundler/ruby_dsl.rb | |
parent | 70d4dcb76ca185120172089b3a8480a69fa6a063 (diff) | |
download | ruby-b4a02502c2125cebd034967027d65ee975987f73.tar.gz |
[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.
Diffstat (limited to 'lib/bundler/ruby_dsl.rb')
0 files changed, 0 insertions, 0 deletions