support break from fiber block; fix #1766

parent 03fde357
......@@ -955,7 +955,7 @@ mrb_context_run(mrb_state *mrb, struct RProc *proc, mrb_value self, unsigned int
if (!ci->target_class) { /* return from context modifying method (resume/yield) */
if (!MRB_PROC_CFUNC_P(ci[-1].proc)) {
proc = ci[-1].proc;
irep = ci[-1].proc->body.irep;
irep = proc->body.irep;
pool = irep->pool;
syms = irep->syms;
}
......@@ -1359,6 +1359,13 @@ mrb_context_run(mrb_state *mrb, struct RProc *proc, mrb_value self, unsigned int
localjump_error(mrb, LOCALJUMP_ERROR_BREAK);
goto L_RAISE;
}
/* break from fiber block */
if (mrb->c->ci == mrb->c->cibase && mrb->c->ci->pc) {
struct mrb_context *c = mrb->c;
mrb->c = c->prev;
c->prev = NULL;
}
ci = mrb->c->ci = mrb->c->cibase + proc->env->cioff + 1;
break;
default:
......
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