Skip to content
Permalink
Browse files
An object attached to a singleton class may not be a class; fix #3587
The fix for #3539 was incomplete.
  • Loading branch information
matz committed Apr 10, 2017
1 parent 0048dd1 commit 9094415acfff11b4590f156eb44cf24483a6fb00
Showing 1 changed file with 12 additions and 3 deletions.
@@ -821,10 +821,19 @@ mrb_mod_cv_set(mrb_state *mrb, struct RClass *c, mrb_sym sym, mrb_value v)

if (cls && cls->tt == MRB_TT_SCLASS) {
mrb_value klass;
klass = mrb_obj_iv_get(mrb, (struct RObject*)cls,
mrb_intern_lit(mrb, "__attached__"));

c = mrb_class_ptr(klass);
klass = mrb_obj_iv_get(mrb, (struct RObject*)cls,
mrb_intern_lit(mrb, "__attached__"));
switch (mrb_type(klass)) {
case MRB_TT_CLASS:
case MRB_TT_MODULE:
case MRB_TT_SCLASS:
c = mrb_class_ptr(klass);
break;
default:
c = cls;
break;
}
}
else{
c = cls;

0 comments on commit 9094415

Please sign in to comment.