Actions
Bug #22712
closedYJIT sometimes does not pass &block_argument properly with super
Bug #22712:
YJIT sometimes does not pass &block_argument properly with super
Description
# --yjit-call-threshold=1
class A
def foo(x) = block_given? ? :got_block : :no_block
end
class B < A
def foo(x) = super(x, &nil)
end
b = B.new
arg = b
arg = 0 if ENV['MASK']
p(b.foo(arg) {}) # => :got_block, should be :no_block
The argument being an instance of B is important. YJIT's reading of the wrong slot for super's is-a check can easily mask this bug as invokesuper_defined_class_mismatch.
Updated by alanwu (Alan Wu) about 23 hours ago
- Description updated (diff)
Updated by alanwu (Alan Wu) about 4 hours ago
- Status changed from Open to Closed
Applied in changeset git|482ed359874e665af66cb391cde74f0ba3630a13.
YJIT: Pass the block argument for super(&blk) [Bug #22712]
Previously, in super, YJIT forwarded the current frame's block handler,
even when it should instead pass the block argument:
class A
def foo(x) = block_given? ? :got_block : :no_block
end
class B < A
def foo(x) = super(x, &nil)
end
b = B.new
b.foo(b) { } # => :got_block, should be :no_block
Also, YJIT reads the receiver at compile time for super's is-a check,
and previously, YJIT read the wrong VM stack slot under the presence of
a block arg.
Leave the block argument to gen_send_iseq() and gen_send_cfunc(), as
with other sends.
Actions