Skip to content

Commit

Permalink
Don't call to_s in const_set
Browse files Browse the repository at this point in the history
Follow up for 5e16857. 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`.
  • Loading branch information
XrXr authored and nobu committed Sep 3, 2020
1 parent 50b18e8 commit 7b9ef66
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion variable.c
Expand Up @@ -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));
Expand Down

0 comments on commit 7b9ef66

Please sign in to comment.