Better error message for malformed IGNORE declarations.
authorStas Boukarev <stassats@gmail.com>
Wed, 16 May 2012 15:04:21 +0000 (19:04 +0400)
committerStas Boukarev <stassats@gmail.com>
Wed, 16 May 2012 15:04:21 +0000 (19:04 +0400)
Give better errors for things like (ignore (a)) and
(ignore (function . b)).

Fixes lp#1000239.

NEWS
src/compiler/ir1tran.lisp
tests/compiler.pure.lisp

diff --git a/NEWS b/NEWS
index a4f9d84..3e7bb67 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -66,6 +66,8 @@ 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.
+    (lp#1000239)
   * documentation:
     ** improved docstrings: REPLACE (lp#965592)
 
index 8a4cf1a..20f7a94 100644 (file)
 ;;; like FIND-IN-BINDINGS, but looks for #'FOO in the FVARS
 (defun find-in-bindings-or-fbindings (name vars fvars)
   (declare (list vars fvars))
-  (if (consp name)
-      (destructuring-bind (wot fn-name) name
-        (unless (eq wot 'function)
-          (compiler-error "The function or variable name ~S is unrecognizable."
-                          name))
-        (find fn-name fvars :key #'leaf-source-name :test #'equal))
-      (find-in-bindings vars name)))
+  (typecase name
+    (atom
+     (find-in-bindings vars name))
+    ((cons (eql function) (cons * null))
+     (find (cadr name) fvars :key #'leaf-source-name :test #'equal))
+    (t
+     (compiler-error "Malformed function or variable name ~S." name))))
 
 ;;; Process an ignore/ignorable declaration, checking for various losing
 ;;; conditions.
index 68b37d1..78f285d 100644 (file)
                                     ,@(loop for i from 27 to 32
                                             collect (expt 2 i)))))))
     (assert (every #'plusp (funcall f #'list)))))
+
+(with-test (:name (:malformed-ignore :lp-1000239))
+  (raises-error?
+   (eval '(lambda () (declare (ignore (function . a)))))
+   sb-int:compiled-program-error)
+  (raises-error?
+   (eval '(lambda () (declare (ignore (function a b)))))
+   sb-int:compiled-program-error)
+  (raises-error?
+   (eval '(lambda () (declare (ignore (function)))))
+   sb-int:compiled-program-error)
+  (raises-error?
+   (eval '(lambda () (declare (ignore (a)))))
+   sb-int:compiled-program-error)
+  (raises-error?
+   (eval '(lambda () (declare (ignorable (a b)))))
+   sb-int:compiled-program-error))