diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2017-07-19 09:03:07 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2017-07-19 09:03:07 +0900 |
| commit | 14a72b08007a345664a0e2e1a53874aaf576f96c (patch) | |
| tree | 5b82ade0a42bb7ac3e3a6e3a6d116f55ff8dec97 /src/class.c | |
| parent | a8bffdae50f623813fbe3294433aef847ed0bd81 (diff) | |
| download | mruby-14a72b08007a345664a0e2e1a53874aaf576f96c.tar.gz mruby-14a72b08007a345664a0e2e1a53874aaf576f96c.zip | |
Avoid constant-set duplication; ref #3747
Diffstat (limited to 'src/class.c')
| -rw-r--r-- | src/class.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/class.c b/src/class.c index dd889cbbf..41a0fbad8 100644 --- a/src/class.c +++ b/src/class.c @@ -2178,10 +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); - if (mrb_type(value) == MRB_TT_CLASS || mrb_type(value) == MRB_TT_MODULE) { + 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); } - mrb_const_set(mrb, mod, id, value); + else { + mrb_const_set(mrb, mod, id, value); + } return value; } |
