From b9e6580135d20cf3fff2e872b3e54c08e96468cb Mon Sep 17 00:00:00 2001 From: eileencodes Date: Wed, 8 Feb 2023 15:27:28 -0500 Subject: Copy cvar table on clone When a class with a class variable is cloned we need to also copy the cvar cache table from the original table to the clone. I found this bug while working on fixing [Bug #19379]. While this does not fix that bug directly it is still a required change to fix another bug revealed by the fix in https://github.com/ruby/ruby/pull/7265 This needs to be backported to 3.2.x and 3.1.x. Co-authored-by: Aaron Patterson --- test/ruby/test_variable.rb | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'test/ruby/test_variable.rb') diff --git a/test/ruby/test_variable.rb b/test/ruby/test_variable.rb index 195f5c94fb..b7892f0cdc 100644 --- a/test/ruby/test_variable.rb +++ b/test/ruby/test_variable.rb @@ -33,6 +33,12 @@ class TestVariable < Test::Unit::TestCase end end + Athena = Gods.clone + + def test_cloned_classes_copy_cvar_cache + assert_equal "Cronus", Athena.new.ruler0 + end + def test_setting_class_variable_on_module_through_inheritance mod = Module.new mod.class_variable_set(:@@foo, 1) -- cgit v1.2.3