mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
mruby should be throw a NameError, if class variable is not exist.
This commit is contained in:
@@ -676,6 +676,8 @@ mrb_mod_class_variables(mrb_state *mrb, mrb_value mod)
|
||||
mrb_value
|
||||
mrb_mod_cv_get(mrb_state *mrb, struct RClass * c, mrb_sym sym)
|
||||
{
|
||||
struct RClass * cls = c;
|
||||
|
||||
while (c) {
|
||||
if (c->iv) {
|
||||
iv_tbl *t = c->iv;
|
||||
@@ -686,6 +688,9 @@ mrb_mod_cv_get(mrb_state *mrb, struct RClass * c, mrb_sym sym)
|
||||
}
|
||||
c = c->super;
|
||||
}
|
||||
mrb_raisef(mrb, E_NAME_ERROR, "uninitialized class variable %s in %s",
|
||||
mrb_sym2name(mrb, sym), mrb_class_name(mrb, cls));
|
||||
/* not reached */
|
||||
return mrb_nil_value();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user