Set the ORPHAN flag in `Proc.new`; fix
MODIFY
src/proc.c
src/proc.c
@@ -163,7 +163,11 @@ mrb_proc_s_new(mrb_state *mrb, mrb_value proc_class)
p = (struct RProc *)mrb_obj_alloc(mrb, MRB_TT_PROC, mrb_class_ptr(proc_class));
mrb_proc_copy(p, mrb_proc_ptr(blk));
proc = mrb_obj_value(p);
- mrb_funcall_with_block(mrb, proc, mrb_intern_lit(mrb, "initialize"), 0, NULL, blk);
+ mrb_funcall_with_block(mrb, proc, mrb_intern_lit(mrb, "initialize"), 0, NULL, proc);
+ if (!MRB_PROC_STRICT_P(p) &&
+ mrb->c->ci > mrb->c->cibase && p->env == mrb->c->ci[-1].env) {
+ p->flags |= MRB_PROC_ORPHAN;
+ }
return proc;
}

Set the ORPHAN flag in `Proc.new`; fix #3798