Actions
Bug #21707
openDestructuring assignment of SimpleDelegator wrapped array bug with YJIT
Bug #21707:
Destructuring assignment of SimpleDelegator wrapped array bug with YJIT
Status:
Open
Assignee:
-
Target version:
-
ruby -v:
ruby 4.0.0dev (2025-11-08T15:08:09Z master 75d25a42e6) +PRISM [x86_64-linux]
Description
Destructuring assignment does not work after a few iterations if YJIT is enabled.
Happens in ruby 3.4.1 and 4.0.0dev.
root@05305c0005f4:/# ruby -v
ruby 4.0.0dev (2025-11-23T19:10:29Z master 8d73a18187) +PRISM [x86_64-linux]
root@05305c0005f4:/# ruby --enable-yjit -rdelegate -e "p 40.times.map { x, = SimpleDelegator.new([1,2,3]); x }"
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, [1, 2, 3], [1, 2, 3], [1, 2, 3], [1, 2, 3], [1, 2, 3], [1, 2, 3], [1, 2, 3], [1, 2, 3], [1, 2, 3], [1, 2, 3], [1, 2, 3]]
Works perfectly if yjit is disabled or zjit is enabled.
root@05305c0005f4:/# ruby --disable-yjit -rdelegate -e "p 40.times.map { x, = SimpleDelegator.new([1,2,3]); x }"
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
root@05305c0005f4:/# ruby --enable-zjit -rdelegate -e "p 40.times.map { x, = SimpleDelegator.new([1,2,3]); x }"
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
Found in a code like this:
code = '1;' * 100
lex_result = Prism.lex_compat(code) # Prism::LexCompat::Token is a subclass of SimpleDelegator
lex_result.value.map do |(pos, kind, text, state)|
p pos
end
No data to display
Actions