Skip to content

Commit

Permalink
Die on unexpected arguments.
Browse files Browse the repository at this point in the history
Handles both positional and named case. This clears up many of the
remaining S06 test files with failures.
  • Loading branch information
jnthn committed Jul 15, 2013
1 parent 9bdb5bc commit 37bf15c
Showing 1 changed file with 32 additions and 1 deletion.
33 changes: 32 additions & 1 deletion src/vm/jvm/runtime/org/perl6/rakudo/Binder.java
Expand Up @@ -834,7 +834,38 @@ else if (!suppressArityFail) {
} }
} }


/* XXX TODO. */ /* Do we have any left-over args? */
if (curPosArg < numPosArgs && !suppressArityFail) {
/* Oh noes, too many positionals passed. */
if (error != null)
error[0] = arityFail(tc, gcx, params, (int)numParams, numPosArgs, true);
return BIND_RESULT_FAIL;
}
if (namedArgsCopy != null && namedArgsCopy.size() > 0) {
/* Oh noes, unexpected named args. */
if (error != null) {
int numExtra = namedArgsCopy.size();
if (numExtra == 1) {
for (String name : namedArgsCopy.keySet())
error[0] = "Unexpected named parameter '" + name + "' passed";
}
else {
boolean first = true;
error[0] = numExtra + " unexpected named parameters passed (";
for (String name : namedArgsCopy.keySet()) {
if (!first)
error[0] += ", ";
else
first = false;
error[0] += name;
}
error[0] += ")";
}
}
return BIND_RESULT_FAIL;
}

/* If we get here, we're done. */
return BIND_RESULT_OK; return BIND_RESULT_OK;
} }


Expand Down

0 comments on commit 37bf15c

Please sign in to comment.