diff --git a/test/ruby/test_module.rb b/test/ruby/test_module.rb index 685118544e..3786eed4a1 100644 --- a/test/ruby/test_module.rb +++ b/test/ruby/test_module.rb @@ -584,6 +584,8 @@ class TestModule < Test::Unit::TestCase assert_equal(prefix+"N", m.const_get(:N).name) assert_equal(prefix+"O", m.const_get(:O).name) assert_equal(prefix+"C", m.const_get(:C).name) + c = m.class_eval("Bug15891 = Class.new.freeze") + assert_equal(prefix+"Bug15891", c.name) end def test_private_class_method diff --git a/variable.c b/variable.c index ea618cee3d..ebfdf0dcce 100644 --- a/variable.c +++ b/variable.c @@ -2733,8 +2733,10 @@ static void set_namespace_path(VALUE named_namespace, VALUE namespace_path) { struct rb_id_table *const_table = RCLASS_CONST_TBL(named_namespace); - - rb_ivar_set(named_namespace, classpath, namespace_path); + if (!RCLASS_IV_TBL(named_namespace)) { + RCLASS_IV_TBL(named_namespace) = st_init_numtable(); + } + rb_class_ivar_set(named_namespace, classpath, namespace_path); if (const_table) { rb_id_table_foreach(const_table, set_namespace_path_i, &namespace_path); }