summaryrefslogtreecommitdiffhomepage
path: root/src/variable.c
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2017-10-31 08:40:22 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2017-10-31 09:10:08 +0900
commitddfb24908c701b742edbad171da395e16c8cda1a (patch)
tree92905644785b42d8e24582419d387afb2def629d /src/variable.c
parent022570ab8d3de0dd8e0acfb1d927a5e3547ea34e (diff)
downloadmruby-ddfb24908c701b742edbad171da395e16c8cda1a.tar.gz
mruby-ddfb24908c701b742edbad171da395e16c8cda1a.zip
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.
Diffstat (limited to 'src/variable.c')
-rw-r--r--src/variable.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/src/variable.c b/src/variable.c
index 3e84c573c..c82f2a822 100644
--- a/src/variable.c
+++ b/src/variable.c
@@ -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);
}