Permalink
Browse files

Need to raise "break from proc-closure" error; fix #3359 fix #3495

Some examples in #3359 still behave differently from CRuby.
  • Loading branch information...
matz committed Apr 19, 2017
1 parent 283d145 commit 77c2aa7b8aaf2c3611189e84c48ac3ee74d2f47d
Showing with 8 additions and 3 deletions.
  1. +8 −3 src/vm.c
View
@@ -1803,8 +1803,13 @@ mrb_vm_exec(mrb_state *mrb, struct RProc *proc, mrb_code *pc)
ci = mrb->c->ci;
break;
case OP_R_BREAK:
if (!proc->env || !MRB_ENV_STACK_SHARED_P(proc->env)) {
localjump_error(mrb, LOCALJUMP_ERROR_BREAK);
if (ci->acc < 0 || !proc->env || !MRB_ENV_STACK_SHARED_P(proc->env)) {
mrb_value exc;
L_BREAK_ERROR:
exc = mrb_exc_new_str_lit(mrb, E_LOCALJUMP_ERROR,
"break from proc-closure");
mrb_exc_set(mrb, exc);
goto L_RAISE;
}
/* break from fiber block */
@@ -1820,7 +1825,7 @@ mrb_vm_exec(mrb_state *mrb, struct RProc *proc, mrb_code *pc)
while (ci > mrb->c->ci) {
if (ci[-1].acc == CI_ACC_SKIP) {
mrb->c->ci = ci;
break;
goto L_BREAK_ERROR;
}
if (ci->env) {
mrb_env_unshare(mrb, ci->env);

0 comments on commit 77c2aa7

Please sign in to comment.