summaryrefslogtreecommitdiffhomepage
path: root/mrbgems/mruby-compiler/core/parse.y
diff options
context:
space:
mode:
Diffstat (limited to 'mrbgems/mruby-compiler/core/parse.y')
-rw-r--r--mrbgems/mruby-compiler/core/parse.y15
1 files changed, 14 insertions, 1 deletions
diff --git a/mrbgems/mruby-compiler/core/parse.y b/mrbgems/mruby-compiler/core/parse.y
index 7280390a7..123c6c0c2 100644
--- a/mrbgems/mruby-compiler/core/parse.y
+++ b/mrbgems/mruby-compiler/core/parse.y
@@ -265,6 +265,7 @@ local_unnest(parser_state *p)
static mrb_bool
local_var_p(parser_state *p, mrb_sym sym)
{
+ struct RProc *u;
node *l = p->locals;
while (l) {
@@ -275,6 +276,18 @@ local_var_p(parser_state *p, mrb_sym sym)
}
l = l->cdr;
}
+
+ u = p->upper;
+ while (u && !MRB_PROC_CFUNC_P(u)) {
+ struct mrb_irep *ir = u->body.irep;
+ uint_fast16_t n = ir->nlocals;
+ const struct mrb_locals *v = ir->lv;
+ for (; n > 1; n --, v ++) {
+ if (v->name == sym) return TRUE;
+ }
+ if (MRB_PROC_SCOPE_P(u)) break;
+ u = u->upper;
+ }
return FALSE;
}
@@ -6192,7 +6205,7 @@ parser_init_cxt(parser_state *p, mrbc_context *cxt)
}
p->capture_errors = cxt->capture_errors;
p->no_optimize = cxt->no_optimize;
- p->on_eval = cxt->on_eval;
+ p->upper = cxt->upper;
if (cxt->partial_hook) {
p->cxt = cxt;
}