From 07e8f800408c412f90f26ddb85b497beec3f1ce6 Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Mon, 6 Jan 2014 14:04:50 +0900 Subject: adjust proc->target_class according to surrounding proc->target_class; based on a patch from @Fleurer; close #1627 --- src/proc.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/proc.c') diff --git a/src/proc.c b/src/proc.c index b2bbe2453..1ae1d495e 100644 --- a/src/proc.c +++ b/src/proc.c @@ -17,9 +17,16 @@ struct RProc * mrb_proc_new(mrb_state *mrb, mrb_irep *irep) { struct RProc *p; + mrb_callinfo *ci = mrb->c->ci; 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->env = 0; mrb_irep_incref(mrb, irep); -- cgit v1.2.3