summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/variable.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/variable.c b/src/variable.c
index 501bed5a6..a1a7f2e82 100644
--- a/src/variable.c
+++ b/src/variable.c
@@ -10,6 +10,7 @@
#include "mruby/variable.h"
#include "error.h"
#include "mruby/array.h"
+#include "mruby/proc.h"
#ifdef ENABLE_REGEXP
#include "re.h"
@@ -342,7 +343,10 @@ mrb_const_get(mrb_state *mrb, mrb_value mod, mrb_sym sym)
mrb_value
mrb_vm_const_get(mrb_state *mrb, mrb_sym sym)
{
- return const_get(mrb, mrb->ci->target_class, sym);
+ struct RClass *c = mrb->ci->proc->target_class;
+
+ if (!c) c = mrb->ci->target_class;
+ return const_get(mrb, c, sym);
}
void
@@ -355,7 +359,10 @@ 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)
{
- mrb_obj_iv_set(mrb, (struct RObject*)mrb->ci->target_class, sym, v);
+ struct RClass *c = mrb->ci->proc->target_class;
+
+ if (!c) c = mrb->ci->target_class;
+ mrb_obj_iv_set(mrb, (struct RObject*)c, sym, v);
}
void