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

ruby-changes:62816

From: Alan <ko1@a...>
Date: Thu, 3 Sep 2020 16:50:00 +0900 (JST)
Subject: [ruby-changes:62816] 7b9ef66747 (master): Don't call to_s in const_set

https://git.ruby-lang.org/ruby.git/commit/?id=7b9ef66747

From 7b9ef66747c91823bf22346ddda7b48329f29fb8 Mon Sep 17 00:00:00 2001
From: Alan Wu <XrXr@u...>
Date: Wed, 2 Sep 2020 13:58:29 -0400
Subject: Don't call to_s in const_set

Follow up for 5e16857315bf55307c5fc887ca6f03bfa0630a93. Calling a method
in the middle of const_set adds a way that it would fail. It also makes
it inconsistent with declaring a constant using `::`, which doesn't call
`to_s`.

diff --git a/variable.c b/variable.c
index 3c3b689..5dd286b 100644
--- a/variable.c
+++ b/variable.c
@@ -2855,7 +2855,8 @@ rb_const_set(VALUE klass, ID id, VALUE val) https://github.com/ruby/ruby/blob/trunk/variable.c#L2855
                 int parental_path_permanent;
                 VALUE parental_path = classname(klass, &parental_path_permanent);
                 if (NIL_P(parental_path)) {
-                    parental_path = rb_funcall(klass, rb_intern("to_s"), 0);
+                    int throwaway;
+                    parental_path = rb_tmp_class_path(klass, &throwaway, make_temporary_path);
                 }
                 if (parental_path_permanent && !val_path_permanent) {
                     set_namespace_path(val, build_const_path(parental_path, id));
-- 
cgit v0.10.2


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

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