Skip to content

Commit

Permalink
An object attached to a singleton class may not be a class; fix #3587
Browse files Browse the repository at this point in the history
The fix for #3539 was incomplete.
  • Loading branch information
matz committed Apr 10, 2017
1 parent 0048dd1 commit 9094415
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/variable.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 9094415

Please sign in to comment.