summaryrefslogtreecommitdiff
path: root/variable.c
diff options
context:
space:
mode:
Diffstat (limited to 'variable.c')
-rw-r--r--variable.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/variable.c b/variable.c
index 26928ca0bc..3c3b689889 100644
--- a/variable.c
+++ b/variable.c
@@ -2854,14 +2854,15 @@ rb_const_set(VALUE klass, ID id, VALUE val)
else {
int parental_path_permanent;
VALUE parental_path = classname(klass, &parental_path_permanent);
- if (!NIL_P(parental_path)) {
- if (parental_path_permanent && !val_path_permanent) {
- 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));
- }
- }
+ if (NIL_P(parental_path)) {
+ parental_path = rb_funcall(klass, rb_intern("to_s"), 0);
+ }
+ if (parental_path_permanent && !val_path_permanent) {
+ 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));
+ }
}
}
}