Permalink
Browse files

Make `break` in lambdas work as `return` according to CRuby behavior.

  • Loading branch information...
matz committed Jun 2, 2017
1 parent 7f417ad commit ab85d3c81478a88748ad76521ceab62115cc009d
Showing with 3 additions and 1 deletion.
  1. +1 −1 src/backtrace.c
  2. +2 −0 src/vm.c
View
@@ -168,7 +168,7 @@ static mrb_value
packed_backtrace(mrb_state *mrb)
{
struct RData *backtrace;
mrb_int ciidx = mrb->c->ci - mrb->c->cibase;
ptrdiff_t ciidx = mrb->c->ci - mrb->c->cibase;
mrb_int len = (ciidx+1)*sizeof(struct backtrace_location);
void *ptr;
View
@@ -1841,6 +1841,7 @@ mrb_vm_exec(mrb_state *mrb, struct RProc *proc, mrb_code *pc)
break;
}
case OP_R_NORMAL:
NORMAL_RETURN:
if (ci == mrb->c->cibase) {
if (!mrb->c->prev) { /* toplevel return */
localjump_error(mrb, LOCALJUMP_ERROR_RETURN);
@@ -1862,6 +1863,7 @@ mrb_vm_exec(mrb_state *mrb, struct RProc *proc, mrb_code *pc)
ci = mrb->c->ci;
break;
case OP_R_BREAK:
if (MRB_PROC_STRICT_P(proc)) goto NORMAL_RETURN;
if (!proc->env || !MRB_ENV_STACK_SHARED_P(proc->env)) {
mrb_value exc;

0 comments on commit ab85d3c

Please sign in to comment.