Find Class/Module in nested singleton class; fix
MODIFY
src/variable.c
src/variable.c
@@ -953,14 +953,13 @@ mrb_vm_const_get(mrb_state *mrb, mrb_sym sym)
if (c->iv && iv_get(mrb, c->iv, sym, &v)) {
return v;
}
- if (c->tt == MRB_TT_SCLASS) {
+ for (c2 = c; c2 && c2->tt == MRB_TT_SCLASS;) {
mrb_value klass;
- klass = mrb_obj_iv_get(mrb, (struct RObject *)c,
+ klass = mrb_obj_iv_get(mrb, (struct RObject *)c2,
mrb_intern_lit(mrb, "__attached__"));
c2 = mrb_class_ptr(klass);
- if (c2->tt == MRB_TT_CLASS || c2->tt == MRB_TT_MODULE)
- c = c2;
}
+ if (c2->tt == MRB_TT_CLASS || c2->tt == MRB_TT_MODULE) c = c2;
c2 = c;
for (;;) {
c2 = mrb_class_outer_module(mrb, c2);

Find Class/Module in nested singleton class; fix #3598