From eb459ec23eda2040d01a4200e0e7d4edb7e872a1 Mon Sep 17 00:00:00 2001 From: Nikodemus Siivola Date: Sun, 3 Dec 2006 12:02:52 +0000 Subject: [PATCH] 1.0.0.13: proper treatment of &whole and friends in ordinary lambda-lists * It is not clear the CLHS really prohibits them from being used as variables, but at least the error should not be a BUG. (reported by Berki Lukacs Tamas) --- NEWS | 2 ++ src/compiler/parse-lambda-list.lisp | 19 ++++++++++++++++--- tests/compiler.impure.lisp | 15 +++++++++++++++ version.lisp-expr | 2 +- 4 files changed, 34 insertions(+), 4 deletions(-) diff --git a/NEWS b/NEWS index 107b7f4..e8d49a3 100644 --- a/NEWS +++ b/NEWS @@ -13,6 +13,8 @@ changes in sbcl-1.0.1 relative to sbcl-1.0: SLOT-UNBOUND. (reported by Pascal Costanza) * bug fix: an error was signaled at startup if the HOME environment variable was defined, but had an empty value (reported by Peter Van Eynde) + * bug fix: non ordinary lambda-list keyword in ordinary lambda lists + signal a PROGRAM-ERROR, not a BUG. * optimization: loading generic functions no longer takes O(n^2) time, proportional to the amount of methods in the generic function (reported by Todd Sabin and Jeremy Brown) diff --git a/src/compiler/parse-lambda-list.lisp b/src/compiler/parse-lambda-list.lisp index d98953b..5569eb3 100644 --- a/src/compiler/parse-lambda-list.lisp +++ b/src/compiler/parse-lambda-list.lisp @@ -104,7 +104,21 @@ (compiler-error "multiple &AUX in lambda list: ~S" list)) (setq auxp t state :aux)) - (t (bug "unknown LAMBDA-LIST-KEYWORD in lambda list: ~S." arg))) + (t + ;; It could be argued that &WHOLE and friends would be just ordinary + ;; variables in an ordinary lambda-list, but since (1) it seem exceedingly + ;; unlikely that that was that the programmer actually ment (2) the spec + ;; can be interpreted as giving as licence to signal an error[*] we do. + ;; + ;; [* All lambda list keywords used in the + ;; implementation appear in LAMBDA-LIST-KEYWORDS. Each + ;; member of a lambda list is either a parameter + ;; specifier ot a lambda list keyword. Ergo, symbols + ;; appearing in LAMBDA-LIST-KEYWORDS cannot be + ;; parameter specifiers.] + (compiler-error 'simple-program-error + :format-control "Bad lambda list keyword ~S in: ~S" + :format-arguments (list arg list)))) (progn (when (symbolp arg) (let ((name (symbol-name arg))) @@ -144,12 +158,11 @@ ;;; even if they could conceivably be legal in not-quite-a-lambda-list ;;; weirdosities (defun parse-lambda-list (lambda-list) - ;; Classify parameters without checking their validity individually. (multiple-value-bind (required optional restp rest keyp keys allowp auxp aux morep more-context more-count) (parse-lambda-list-like-thing lambda-list) - + ;; Check validity of parameters. (flet ((need-symbol (x why) (unless (symbolp x) diff --git a/tests/compiler.impure.lisp b/tests/compiler.impure.lisp index 7d9a58f..a3d6f33 100644 --- a/tests/compiler.impure.lisp +++ b/tests/compiler.impure.lisp @@ -1401,4 +1401,19 @@ ((and (not style-warning) warning) (e) (error e))) +;;; program-error from bad lambda-list keyword +(assert (eq :ok + (handler-case + (funcall (lambda (&whole x) + (list &whole x))) + (program-error () + :ok)))) +(assert (eq :ok + (handler-case + (let ((*evaluator-mode* :interpret)) + (funcall (eval '(lambda (&whole x) + (list &whole x))))) + (program-error () + :ok)))) + ;;; success diff --git a/version.lisp-expr b/version.lisp-expr index d70f6ba..ffb4122 100644 --- a/version.lisp-expr +++ b/version.lisp-expr @@ -17,4 +17,4 @@ ;;; checkins which aren't released. (And occasionally for internal ;;; versions, especially for internal versions off the main CVS ;;; branch, it gets hairier, e.g. "0.pre7.14.flaky4.13".) -"1.0.0.12" +"1.0.0.13" -- 1.7.10.4