mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
Fixed constant (and class variable) reference bug; fix #3839
Unlike method definition, constant reference should start from `MRB_PROC_TARGET_CLASS(ci->proc)`, not `ci->target_class`. In addition, `MRB_PROC_TARGET_CLASS(ci->proc)` is always set.
This commit is contained in:
+3
-6
@@ -635,7 +635,6 @@ mrb_vm_cv_get(mrb_state *mrb, mrb_sym sym)
|
||||
struct RClass *c;
|
||||
|
||||
c = MRB_PROC_TARGET_CLASS(mrb->c->ci->proc);
|
||||
if (!c) c = mrb->c->ci->target_class;
|
||||
return mrb_mod_cv_get(mrb, c, sym);
|
||||
}
|
||||
|
||||
@@ -645,7 +644,6 @@ mrb_vm_cv_set(mrb_state *mrb, mrb_sym sym, mrb_value v)
|
||||
struct RClass *c;
|
||||
|
||||
c = MRB_PROC_TARGET_CLASS(mrb->c->ci->proc);
|
||||
if (!c) c = mrb->c->ci->target_class;
|
||||
mrb_mod_cv_set(mrb, c, sym, v);
|
||||
}
|
||||
|
||||
@@ -707,9 +705,6 @@ mrb_vm_const_get(mrb_state *mrb, mrb_sym sym)
|
||||
struct RProc *proc;
|
||||
|
||||
c = MRB_PROC_TARGET_CLASS(mrb->c->ci->proc);
|
||||
if (!c) c = mrb->c->ci->target_class;
|
||||
mrb_assert(c != NULL);
|
||||
|
||||
if (c->iv && iv_get(mrb, c->iv, sym, &v)) {
|
||||
return v;
|
||||
}
|
||||
@@ -746,7 +741,9 @@ mrb_const_set(mrb_state *mrb, mrb_value mod, mrb_sym sym, mrb_value v)
|
||||
void
|
||||
mrb_vm_const_set(mrb_state *mrb, mrb_sym sym, mrb_value v)
|
||||
{
|
||||
struct RClass *c = mrb->c->ci->target_class;
|
||||
struct RClass *c;
|
||||
|
||||
c = MRB_PROC_TARGET_CLASS(mrb->c->ci->proc);
|
||||
mrb_obj_iv_set(mrb, (struct RObject*)c, sym, v);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user