From: "tompng (tomoya ishida) via ruby-core" Date: 2025-11-23T21:14:04+00:00 Subject: [ruby-core:123889] [Ruby Bug#21707] Destructuring assignment of SimpleDelegator wrapped array bug with YJIT Issue #21707 has been reported by tompng (tomoya ishida). ---------------------------------------- Bug #21707: Destructuring assignment of SimpleDelegator wrapped array bug with YJIT https://bugs.ruby-lang.org/issues/21707 * Author: tompng (tomoya ishida) * Status: Open * ruby -v: ruby 4.0.0dev (2025-11-08T15:08:09Z master 75d25a42e6) +PRISM [x86_64-linux] * Backport: 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN ---------------------------------------- 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: ~~~ruby 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 ~~~ -- https://bugs.ruby-lang.org/ ______________________________________________ ruby-core mailing list -- ruby-core@ml.ruby-lang.org To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/