diff options
-rw-r--r-- | test/ruby/test_class.rb | 7 | ||||
-rw-r--r-- | variable.c | 2 |
2 files changed, 8 insertions, 1 deletions
diff --git a/test/ruby/test_class.rb b/test/ruby/test_class.rb index 6a8234a9d3..368c046261 100644 --- a/test/ruby/test_class.rb +++ b/test/ruby/test_class.rb @@ -730,4 +730,11 @@ class TestClass < Test::Unit::TestCase end; end + + def test_assign_frozen_class_to_const + c = Class.new.freeze + assert_same(c, Module.new.module_eval("self::Foo = c")) + c = Class.new.freeze + assert_same(c, Module.new.const_set(:Foo, c)) + end end diff --git a/variable.c b/variable.c index 52da16f0df..92d7d11eab 100644 --- a/variable.c +++ b/variable.c @@ -3058,7 +3058,7 @@ rb_const_set(VALUE klass, ID id, VALUE val) set_namespace_path(val, build_const_path(parental_path, id)); } else if (!parental_path_permanent && NIL_P(val_path)) { - rb_ivar_set(val, tmp_classpath, build_const_path(parental_path, id)); + ivar_set(val, tmp_classpath, build_const_path(parental_path, id)); } } } |