From 36d9136bc698c1c23accaf5cc324cc286dbb62e5 Mon Sep 17 00:00:00 2001 From: Stas Boukarev Date: Wed, 16 May 2012 20:30:04 +0400 Subject: [PATCH] Better error for malformed type declarations. Give proper error messages for things like (declare (type (integer 1 . 2) a)). --- NEWS | 2 +- src/code/parse-defmacro-errors.lisp | 6 ++++-- tests/compiler.pure.lisp | 3 +++ 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/NEWS b/NEWS index 3e7bb67..dbeaa82 100644 --- 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) diff --git a/src/code/parse-defmacro-errors.lisp b/src/code/parse-defmacro-errors.lisp index 70cf9d8..b98ec52 100644 --- a/src/code/parse-defmacro-errors.lisp +++ b/src/code/parse-defmacro-errors.lisp @@ -79,8 +79,10 @@ (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) diff --git a/tests/compiler.pure.lisp b/tests/compiler.pure.lisp index 78f285d..780b3d2 100644 --- a/tests/compiler.pure.lisp +++ b/tests/compiler.pure.lisp @@ -4271,3 +4271,6 @@ (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))))) -- 1.7.10.4