Skip to content

Commit

Permalink
Only consider break jumps actually originating from this proc.
Browse files Browse the repository at this point in the history
Fixes #1270 on master.
  • Loading branch information
headius committed Mar 2, 2015
1 parent c4cdb07 commit fad37ea
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions core/src/main/java/org/jruby/ir/runtime/IRRuntimeHelpers.java
Original file line number Diff line number Diff line change
Expand Up @@ -183,21 +183,23 @@ public static IRubyObject initiateBreak(ThreadContext context, DynamicScope dynS
}
}

@JIT
@Interp @JIT
public static IRubyObject handleBreakAndReturnsInLambdas(ThreadContext context, StaticScope scope, DynamicScope dynScope, Object exc, Block.Type blockType) throws RuntimeException {
if ((exc instanceof IRBreakJump) && inNonMethodBodyLambda(scope, blockType)) {
// We just unwound all the way up because of a non-local break
throw IRException.BREAK_LocalJumpError.getException(context.getRuntime());
} else if (exc instanceof IRReturnJump && (blockType == null || inLambda(blockType))) {
if (((IRBreakJump)exc).scopeToReturnTo == dynScope) throw IRException.BREAK_LocalJumpError.getException(context.getRuntime());
}

if (exc instanceof IRReturnJump && (blockType == null || inLambda(blockType))) {
// Ignore non-local return processing in non-lambda blocks.
// Methods have a null blocktype
return handleNonlocalReturn(scope, dynScope, exc, blockType);
} else {
// Propagate
Helpers.throwException((Throwable)exc);
// should not get here
return null;
}

// Propagate
Helpers.throwException((Throwable)exc);
// should not get here
return null;
}

@JIT
Expand Down

0 comments on commit fad37ea

Please sign in to comment.