From: "jhawthorn (John Hawthorn) via ruby-core" Date: 2026-04-01T18:50:38+00:00 Subject: [ruby-core:125176] [Ruby Bug#21978] Fix class variable cache isn't invalidated via modules Issue #21978 has been reported by jhawthorn (John Hawthorn). ---------------------------------------- Bug #21978: Fix class variable cache isn't invalidated via modules https://bugs.ruby-lang.org/issues/21978 * Author: jhawthorn (John Hawthorn) * Status: Open * Backport: 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN, 4.0: UNKNOWN ---------------------------------------- ```ruby module M; @@x = 1; end class A; end class B < A include M def self.x; @@x; end end B.x # warm cache A.class_variable_set(:@@x, 2) B.x ``` The last call to `B.x` should fail with `Should raise: class variable @@x of M is overtaken by A (RuntimeError)`, but has been returning 1 since since ruby-3.2.0-preview3. It should be solvable by by bumping the global state counter more aggressively: https://github.com/ruby/ruby/pull/16551 -- 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/