Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Die on unexpected arguments.

Handles both positional and named case. This clears up many of the
remaining S06 test files with failures.
  • Loading branch information...
commit 37bf15c2a110f4ed7b87b2ee815682bc235b48bc 1 parent 9bdb5bc
Jonathan Worthington jnthn authored
Showing with 32 additions and 1 deletion.
  1. +32 −1 src/vm/jvm/runtime/org/perl6/rakudo/Binder.java
33 src/vm/jvm/runtime/org/perl6/rakudo/Binder.java
View
@@ -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;
}
Please sign in to comment.
Something went wrong with that request. Please try again.