Skip to content
Permalink
Browse files
class variables in higher order have a priority; fix #3235
  • Loading branch information
matz committed Nov 8, 2016
1 parent 1142cf2 commit 872517dff372ee6fde92c71861abf6ab9fbab958
Showing 1 changed file with 6 additions and 2 deletions.
@@ -760,26 +760,30 @@ mrb_mod_cv_get(mrb_state *mrb, struct RClass * c, mrb_sym sym)
{
struct RClass * cls = c;
mrb_value v;
int given = FALSE;

while (c) {
if (c->iv && iv_get(mrb, c->iv, sym, &v)) {
return v;
given = TRUE;
}
c = c->super;
}
if (given) return 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);
if (c->tt == MRB_TT_CLASS || c->tt == MRB_TT_MODULE) {
given = FALSE;
while (c) {
if (c->iv && iv_get(mrb, c->iv, sym, &v)) {
return v;
given = TRUE;
}
c = c->super;
}
if (given) return v;
}
}
mrb_name_error(mrb, sym, "uninitialized class variable %S in %S",

0 comments on commit 872517d

Please sign in to comment.