Skip to content

Commit

Permalink
[Truffle] Last of the def-2.0 specs.
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisseaton committed Dec 12, 2014
1 parent 8ddeaaf commit 2df1533
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
Expand Up @@ -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));
}
Expand All @@ -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;
}
}

Expand Down
1 change: 0 additions & 1 deletion spec/truffle/tags/language/versions/def_2.0_tags.txt

This file was deleted.

0 comments on commit 2df1533

Please sign in to comment.