diff options
author | Maple Ong <maple.ong@gusto.com> | 2023-02-09 10:41:29 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-09 10:41:29 -0500 |
commit | 381bdee118532025b9397ea282d6f5ddb65996e0 (patch) | |
tree | ae8fe3f6e213570b96455aa67e06f50ce0fd8b1e /bootstraptest | |
parent | 0601ba6a1bf15e13ac931921861c90535ed29dde (diff) | |
download | ruby-381bdee118532025b9397ea282d6f5ddb65996e0.tar.gz |
YJIT: Support invokesuper in a block (#7264)
Support invokesuper in a block on YJIT
invokesuper previously side exited when it is in a block. To make sure we're compiling the correct method in super, we now use the local environment pointer (LEP) to get the method, which will work in a block.
Co-authored-by: John Hawthorn <john@hawthorn.email>
Diffstat (limited to 'bootstraptest')
-rw-r--r-- | bootstraptest/test_yjit.rb | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/bootstraptest/test_yjit.rb b/bootstraptest/test_yjit.rb index cbb3f145b0..66b663b062 100644 --- a/bootstraptest/test_yjit.rb +++ b/bootstraptest/test_yjit.rb @@ -1940,6 +1940,38 @@ assert_equal '[:A, :Btwo]', %q{ ins.foo } +# invokesuper with a block +assert_equal 'true', %q{ + class A + def foo = block_given? + end + + class B < A + def foo = super() + end + + B.new.foo { } + B.new.foo { } +} + +# invokesuper in a block +assert_equal '[0, 2]', %q{ + class A + def foo(x) = x * 2 + end + + class B < A + def foo + 2.times.map do |x| + super(x) + end + end + end + + B.new.foo + B.new.foo +} + # Call to fixnum assert_equal '[true, false]', %q{ def is_odd(obj) |