From 01cc9978e742a5e3a7882e397b01857bed774501 Mon Sep 17 00:00:00 2001 From: Stas Boukarev Date: Wed, 16 May 2012 19:04:21 +0400 Subject: [PATCH] Better error message for malformed IGNORE declarations. Give better errors for things like (ignore (a)) and (ignore (function . b)). Fixes lp#1000239. --- NEWS | 2 ++ src/compiler/ir1tran.lisp | 14 +++++++------- tests/compiler.pure.lisp | 17 +++++++++++++++++ 3 files changed, 26 insertions(+), 7 deletions(-) diff --git a/NEWS b/NEWS index a4f9d84..3e7bb67 100644 --- 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) diff --git a/src/compiler/ir1tran.lisp b/src/compiler/ir1tran.lisp index 8a4cf1a..20f7a94 100644 --- a/src/compiler/ir1tran.lisp +++ b/src/compiler/ir1tran.lisp @@ -1329,13 +1329,13 @@ ;;; 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. diff --git a/tests/compiler.pure.lisp b/tests/compiler.pure.lisp index 68b37d1..78f285d 100644 --- a/tests/compiler.pure.lisp +++ b/tests/compiler.pure.lisp @@ -4254,3 +4254,20 @@ ,@(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)) -- 1.7.10.4