Skip to content
Permalink
Browse files
[Truffle] Last of the def-2.0 specs.
  • Loading branch information
chrisseaton committed Dec 12, 2014
1 parent 8ddeaaf commit 2df1533ed737aad30869644dfa85cee6db1d51b0
Showing with 11 additions and 12 deletions.
  1. +11 −11 core/src/main/java/org/jruby/truffle/nodes/methods/arguments/CheckArityNode.java
  2. +0 −1 spec/truffle/tags/language/versions/def_2.0_tags.txt
@@ -44,7 +44,7 @@ public CheckArityNode(RubyContext context, SourceSection sourceSection, Arity ar
public void executeVoid(VirtualFrame frame) {
final int given = RubyArguments.getUserArgumentsCount(frame.getArguments());

if (!checkArity(given)) {
if (!checkArity(frame, given)) {
CompilerDirectives.transferToInterpreter();
throw new RaiseException(getContext().getCoreLibrary().argumentError(given, arity.getRequired(), this));
}
@@ -60,17 +60,17 @@ public void executeVoid(VirtualFrame frame) {
}
}

private boolean checkArity(int given) {
if (arity.hasKeywords()) {
return true;
private boolean checkArity(VirtualFrame frame, int given) {
if (arity.hasKeywords() && getKeywordsHash(frame) != null) {
given -= 1;
}

if (arity.getRequired() != 0 && given < arity.getRequired()) {
return false;
} else if (!arity.allowsMore() && given > arity.getRequired() + arity.getOptional()) {
return false;
} else {
if (arity.getRequired() != 0 && given < arity.getRequired()) {
return false;
} else if (!arity.allowsMore() && given > arity.getRequired() + arity.getOptional()) {
return false;
} else {
return true;
}
return true;
}
}

This file was deleted.

0 comments on commit 2df1533

Please sign in to comment.