Changeset 13885


Ignore:
Timestamp:
02/29/12 22:35:41 (9 years ago)
Author:
ehuelsmann
Message:

Report the actual parameters passed in a function call with mismatched
parameter counts.

Location:
trunk/abcl/src/org/armedbear/lisp
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/abcl/src/org/armedbear/lisp/ArgumentListProcessor.java

    r13850 r13885  
    610610            // Fixed arity.
    611611            if (args.length != arity)
    612               error(new WrongNumberOfArgumentsException(function, arity));
     612              error(new WrongNumberOfArgumentsException(function, list(args), arity));
    613613            return args;
    614614          }
     
    640640            // Fixed arity.
    641641            if (argsLength != arity)
    642               error(new WrongNumberOfArgumentsException(function, arity));
     642              error(new WrongNumberOfArgumentsException(function, list(args), arity));
    643643            return args;
    644644          }
  • trunk/abcl/src/org/armedbear/lisp/Lisp.java

    r13822 r13885  
    883883  }
    884884
     885  public static LispObject list(LispObject[] obj) {
     886      LispObject theList = NIL;
     887      if (obj.length > 0)
     888      for (int i = obj.length - 1; i >= 0; i--)
     889          theList = new Cons(obj[i], theList);
     890      return theList;
     891  }
    885892
    886893  public static final Cons list(LispObject obj1, LispObject... remaining)
  • trunk/abcl/src/org/armedbear/lisp/WrongNumberOfArgumentsException.java

    r13510 r13885  
    4141    private int expectedMinArgs;
    4242    private int expectedMaxArgs;
     43    private LispObject actualArgs;
    4344    private String message;
    4445
     
    4748    }
    4849
    49     public WrongNumberOfArgumentsException(Operator operator, int expectedMin,
    50             int expectedMax) {
     50    public WrongNumberOfArgumentsException(Operator operator, LispObject args,
     51            int expectedMin, int expectedMax) {
    5152        // This is really just an ordinary PROGRAM-ERROR, broken out into its
    5253        // own Java class as a convenience for the implementation.
     
    5556  this.expectedMinArgs = expectedMin;
    5657  this.expectedMaxArgs = expectedMax;
     58        this.actualArgs = args;
    5759        setFormatControl(getMessage());
    5860        setFormatArguments(NIL);
    5961    }
    60    
     62
     63    public WrongNumberOfArgumentsException(Operator operator,
     64            int expectedMin, int expectedMax) {
     65        this(operator, null, expectedMin, expectedMax);
     66    }
     67       
    6168    public WrongNumberOfArgumentsException(Operator operator, int expectedArgs) {
    6269        this(operator, expectedArgs, expectedArgs);
    6370    }
    6471
     72    public WrongNumberOfArgumentsException(Operator operator, LispObject args,
     73            int expectedArgs) {
     74        this(operator, args, expectedArgs, expectedArgs);
     75    }
     76   
    6577    public WrongNumberOfArgumentsException(String message) {
    6678        super(StandardClass.PROGRAM_ERROR);
     
    100112      sb.append(" expected");
    101113  }
     114        if (actualArgs != null) {
     115            sb.append(" -- provided: ");
     116            sb.append(actualArgs.princToString());
     117        }
    102118        sb.append('.');
    103119        return message = sb.toString();
Note: See TracChangeset for help on using the changeset viewer.