Skip to content

Commit

Permalink
Added some missing arity checks for lambdas in prepareBlockArgs code
Browse files Browse the repository at this point in the history
* Missing mostly for the zero args case.
* Strange that there were no tests failing for this.
  - Might need to force a test run with full build.
subbuss committed Dec 20, 2015
1 parent ecf6cc9 commit 7c16fea
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions core/src/main/java/org/jruby/ir/runtime/IRRuntimeHelpers.java
Original file line number Diff line number Diff line change
@@ -1519,7 +1519,7 @@ private static IRubyObject[] prepareBlockArgsInternal(ThreadContext context, Blo
// This is the placeholder for scenarios
// not handled by specialized instructions.
if (args == null) {
return IRubyObject.NULL_ARRAY;
args = IRubyObject.NULL_ARRAY;
}

boolean isLambda = block.type == Block.Type.LAMBDA;
@@ -1611,7 +1611,7 @@ public static IRubyObject[] prepareBlockArgs(ThreadContext context, Block block,
@Interp @JIT
public static IRubyObject[] prepareFixedBlockArgs(ThreadContext context, Block block, IRubyObject[] args) {
if (args == null) {
return IRubyObject.NULL_ARRAY;
args = IRubyObject.NULL_ARRAY;
}

boolean isLambda = block.type == Block.Type.LAMBDA;
@@ -1629,6 +1629,7 @@ public static IRubyObject[] prepareFixedBlockArgs(ThreadContext context, Block b
// the single-instruction cases always uses PrepareSingleBlockArgInstr
// But, including this here for robustness for now.
if (block.getBody().getSignature().arityValue() == 1) {
if (isLambda) block.getBody().getSignature().checkArity(context.runtime, args);
return args;
}

@@ -1644,7 +1645,9 @@ public static IRubyObject[] prepareFixedBlockArgs(ThreadContext context, Block b

@Interp @JIT
public static IRubyObject[] prepareSingleBlockArgs(ThreadContext context, Block block, IRubyObject[] args) {
if (args == null) args = IRubyObject.NULL_ARRAY;
if (args == null) {
args = IRubyObject.NULL_ARRAY;
}

if (block.type == Block.Type.LAMBDA) {
block.getBody().getSignature().checkArity(context.runtime, args);

0 comments on commit 7c16fea

Please sign in to comment.