forget to re-initialize target_class for top-level eval; close #1418

parent 961cd408
......@@ -23,6 +23,7 @@ typedef struct mrbc_context {
short lineno;
int (*partial_hook)(struct mrb_parser_state*);
void *partial_data;
struct RClass *target_class;
mrb_bool capture_errors:1;
mrb_bool dump_result:1;
mrb_bool no_exec:1;
......
......@@ -5207,9 +5207,13 @@ mrb_parse_string(mrb_state *mrb, const char *s, mrbc_context *c)
return mrb_parse_nstring(mrb, s, strlen(s), c);
}
struct RProc* mrb_proc_new_with_target(mrb_state *mrb, mrb_irep *irep, struct RClass *target);
static mrb_value
load_exec(mrb_state *mrb, parser_state *p, mrbc_context *c)
{
struct RClass *target = mrb->object_class;
struct RProc *proc;
int n;
mrb_value v;
......@@ -5243,8 +5247,11 @@ load_exec(mrb_state *mrb, parser_state *p, mrbc_context *c)
if (c) {
if (c->dump_result) codedump_all(mrb, n);
if (c->no_exec) return mrb_fixnum_value(n);
if (c->target_class) target = c->target_class;
}
v = mrb_run(mrb, mrb_proc_new(mrb, mrb->irep[n]), mrb_top_self(mrb));
proc = mrb_proc_new(mrb, mrb->irep[n]);
proc->target_class = target;
v = mrb_run(mrb, proc, mrb_top_self(mrb));
if (mrb->exc) return mrb_nil_value();
return v;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment