1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Don't call to_s in const_set

Follow up for 5e16857315. 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`.
This commit is contained in:
Alan Wu 2020-09-02 13:58:29 -04:00 committed by Nobuyoshi Nakada
parent 50b18e8129
commit 7b9ef66747
Notes: git 2020-09-03 16:50:10 +09:00

View file

@ -2855,7 +2855,8 @@ rb_const_set(VALUE klass, ID id, VALUE val)
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));