From 083691dbd19364aceba9cc03f9cbb4eec432422c Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Fri, 22 Apr 2022 15:26:24 +0900 Subject: [PATCH] variable.c (const_get): stop searching constant before `Object`. `String::String` should raise `NameError` exception. --- src/variable.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/variable.c b/src/variable.c index 4f1c8bace..365d93034 100644 --- a/src/variable.c +++ b/src/variable.c @@ -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) { @@ -782,6 +783,7 @@ L_RETRY: return v; } c = c->super; + if (!skip && c == mrb->object_class) break; } if (!retry && base->tt == MRB_TT_MODULE) { c = mrb->object_class;