Skip to content

Commit

Permalink
variable.c (const_get): stop searching constant before Object.
Browse files Browse the repository at this point in the history
`String::String` should raise `NameError` exception.
  • Loading branch information
matz committed Apr 24, 2022
1 parent 17b4d82 commit 083691d
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/variable.c
Original file line number Diff line number Diff line change
Expand Up @@ -774,6 +774,7 @@ const_get(mrb_state *mrb, struct RClass *base, mrb_sym sym, mrb_bool skip)
mrb_bool retry = FALSE;
mrb_value name;

/* if skip then skip the current class (already searched) */
if (skip) c = c->super;
L_RETRY:
while (c) {
Expand All @@ -782,6 +783,7 @@ const_get(mrb_state *mrb, struct RClass *base, mrb_sym sym, mrb_bool skip)
return v;
}
c = c->super;
if (!skip && c == mrb->object_class) break;
}
if (!retry && base->tt == MRB_TT_MODULE) {
c = mrb->object_class;
Expand Down

0 comments on commit 083691d

Please sign in to comment.