Changeset 11835


Ignore:
Timestamp:
05/06/09 18:34:40 (14 years ago)
Author:
vvoutilainen
Message:

Combine check-arg-count and check-min-args with a format
recipe and an optional argument. Note, ansi tests do not
exercise the failure case for check-min-args, but the
format recipe is easy enough to test with the following
snippet:

(format t
"Wrong number of arguments for ~A (expected~:[~; at least~] ~D, but received ~D)."
1 nil 2 3)

By changing the second argument after the format string
from nil to t, both cases can be seen to work with this format
string.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/abcl/src/org/armedbear/lisp/compiler-pass2.lisp

    r11833 r11835  
    10021002;; functions with a wrong number of arguments or malformed keyword argument
    10031003;; lists, and using unrecognized declaration specifiers." (3.2.5)
    1004 (defknown check-arg-count (t fixnum) t)
    1005 (defun check-arg-count (form n)
     1004(defun check-number-of-args (form n &optional (minimum nil))
    10061005  (declare (type fixnum n))
    10071006  (let* ((op (car form))
    10081007         (args (cdr form))
    1009          (ok (= (length args) n)))
     1008         (ok (if minimum
     1009     (>= (length args) n)
     1010         (= (length args) n))))
    10101011    (declare (type boolean ok))
    10111012    (unless ok
     
    10131014                   #'compiler-warn ; See above!
    10141015                   #'compiler-style-warn)
    1015                "Wrong number of arguments for ~A (expected ~D, but received ~D)."
    1016                op n (length args)))
     1016               "Wrong number of arguments for ~A (expected~:[~; at least~] ~D, but received ~D)."
     1017               op minimum n (length args)))
    10171018    ok))
     1019
     1020(defknown check-arg-count (t fixnum) t)
     1021(defun check-arg-count (form n)
     1022  (check-number-of-args form n))
    10181023
    10191024(declaim (ftype (function (t fixnum) t) check-min-args))
    10201025(defun check-min-args (form n)
    1021   (declare (type fixnum n))
    1022   (let* ((op (car form))
    1023          (args (cdr form))
    1024          (ok (>= (length args) n)))
    1025     (unless ok
    1026       (funcall (if (eq (symbol-package op) +cl-package+)
    1027                    #'compiler-warn ; See above!
    1028                    #'compiler-style-warn)
    1029                "Wrong number of arguments for ~A (expected at least ~D, but received ~D)."
    1030                op n (length args)))
    1031     ok))
     1026  (check-number-of-args form n t))
    10321027
    10331028(defun unsupported-opcode (instruction)
Note: See TracChangeset for help on using the changeset viewer.