Better error for malformed type declarations.
authorStas Boukarev <stassats@gmail.com>
Wed, 16 May 2012 16:30:04 +0000 (20:30 +0400)
committerStas Boukarev <stassats@gmail.com>
Wed, 16 May 2012 16:30:04 +0000 (20:30 +0400)
Give proper error messages for things like
(declare (type (integer 1 . 2) a)).

NEWS
src/code/parse-defmacro-errors.lisp
tests/compiler.pure.lisp

diff --git a/NEWS b/NEWS
index 3e7bb67..dbeaa82 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -66,7 +66,7 @@ changes relative to sbcl-1.0.56:
     strictly-monotonic functions.  (lp#975528)
   * bug fix: copy-tree caused stack exhaustion on long linear lists, and now
     it's also slightly faster. (lp#998926)
-  * bug fix: better error messages for malformed IGNORE declarations.
+  * bug fix: better error messages for malformed declarations.
     (lp#1000239)
   * documentation:
     ** improved docstrings: REPLACE (lp#965592)
index 70cf9d8..b98ec52 100644 (file)
               (format stream "between ~W and ~W expected"
                       (arg-count-error-minimum condition)
                       (arg-count-error-maximum condition))))
-       (format stream ", but ~W found"
-               (length (arg-count-error-args condition)))))))
+       (format stream ", but ~a found"
+               (if (null (cdr (last (arg-count-error-args condition))))
+                   (length (arg-count-error-args condition))
+                   "not a proper list"))))))
 
 (define-condition defmacro-lambda-list-broken-key-list-error
                   (defmacro-lambda-list-bind-error)
index 78f285d..780b3d2 100644 (file)
   (raises-error?
    (eval '(lambda () (declare (ignorable (a b)))))
    sb-int:compiled-program-error))
+
+(with-test (:name :malformed-type-declaraions)
+  (compile nil '(lambda (a) (declare (type (integer 1 2 . 3) a)))))