summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2017-07-19 09:03:51 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2017-07-19 09:03:51 +0900
commit645b0fb58c9dda7d15cc42748d74d791380444db (patch)
tree5b82ade0a42bb7ac3e3a6e3a6d116f55ff8dec97 /src
parent329938ef159d54523cb36aa7069abb7c35ec77d8 (diff)
parent14a72b08007a345664a0e2e1a53874aaf576f96c (diff)
downloadmruby-645b0fb58c9dda7d15cc42748d74d791380444db.tar.gz
mruby-645b0fb58c9dda7d15cc42748d74d791380444db.zip
Merge branch 'christopheraue-const_set_mod_to_s'
Diffstat (limited to 'src')
-rw-r--r--src/class.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/class.c b/src/class.c
index e4e177f04..41a0fbad8 100644
--- a/src/class.c
+++ b/src/class.c
@@ -2178,7 +2178,14 @@ mrb_mod_const_set(mrb_state *mrb, mrb_value mod)
mrb_get_args(mrb, "no", &id, &value);
check_const_name_sym(mrb, id);
- mrb_const_set(mrb, mod, id, value);
+ if ((mrb_type(value) == MRB_TT_CLASS || mrb_type(value) == MRB_TT_MODULE)
+ && !mrb_obj_iv_defined(mrb, mrb_obj_ptr(value), mrb_intern_lit(mrb, "__classid__"))) {
+ /* name unnamed classes/modules */
+ setup_class(mrb, mrb_class_ptr(mod), mrb_class_ptr(value), id);
+ }
+ else {
+ mrb_const_set(mrb, mod, id, value);
+ }
return value;
}