[前][次][番号順一覧][スレッド一覧]

ruby-changes:64968

From: Nobuyoshi <ko1@a...>
Date: Wed, 20 Jan 2021 19:24:44 +0900 (JST)
Subject: [ruby-changes:64968] 565aeb81e0 (master): Skip freezing check on setting temporary class path [Bug #17563]

https://git.ruby-lang.org/ruby.git/commit/?id=565aeb81e0

From 565aeb81e0886c835888a425e5d05ed99fb03238 Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Wed, 20 Jan 2021 15:05:30 +0900
Subject: Skip freezing check on setting temporary class path [Bug #17563]

Co-authored-by: ryannevell (Ryan Nevell) <ryan.nevell@g...>

diff --git a/test/ruby/test_class.rb b/test/ruby/test_class.rb
index 6a8234a..368c046 100644
--- a/test/ruby/test_class.rb
+++ b/test/ruby/test_class.rb
@@ -730,4 +730,11 @@ class TestClass < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_class.rb#L730
     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 52da16f..92d7d11 100644
--- a/variable.c
+++ b/variable.c
@@ -3058,7 +3058,7 @@ rb_const_set(VALUE klass, ID id, VALUE val) https://github.com/ruby/ruby/blob/trunk/variable.c#L3058
                     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));
                 }
 	    }
 	}
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]