adjust proc->target_class according to surrounding proc->target_class; based...

adjust proc->target_class according to surrounding proc->target_class; based on a patch from @Fleurer; close #1627
parent 91fbbe2f
...@@ -17,9 +17,16 @@ struct RProc * ...@@ -17,9 +17,16 @@ struct RProc *
mrb_proc_new(mrb_state *mrb, mrb_irep *irep) mrb_proc_new(mrb_state *mrb, mrb_irep *irep)
{ {
struct RProc *p; struct RProc *p;
mrb_callinfo *ci = mrb->c->ci;
p = (struct RProc*)mrb_obj_alloc(mrb, MRB_TT_PROC, mrb->proc_class); p = (struct RProc*)mrb_obj_alloc(mrb, MRB_TT_PROC, mrb->proc_class);
p->target_class = (mrb->c->ci) ? mrb->c->ci->target_class : 0; p->target_class = 0;
if (ci) {
if (ci->proc)
p->target_class = ci->proc->target_class;
if (!p->target_class)
p->target_class = ci->target_class;
}
p->body.irep = irep; p->body.irep = irep;
p->env = 0; p->env = 0;
mrb_irep_incref(mrb, irep); mrb_irep_incref(mrb, irep);
......
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