0.8.10.50:
authorChristophe Rhodes <csr21@cam.ac.uk>
Mon, 24 May 2004 13:38:52 +0000 (13:38 +0000)
committerChristophe Rhodes <csr21@cam.ac.uk>
Mon, 24 May 2004 13:38:52 +0000 (13:38 +0000)
Allow &FOO in lambda lists, with a style-warning, rather than
a full error (as per FIXME and #lisp IRC)

NEWS
src/compiler/parse-lambda-list.lisp
tests/smoke.impure.lisp
version.lisp-expr

diff --git a/NEWS b/NEWS
index e014912..dcd278d 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -2455,6 +2455,9 @@ changes in sbcl-0.8.11 relative to sbcl-0.8.10:
     functions.
   * fixed bug: the #S reader macro performs the keyword coercion
     specified for slot names.  (reported by Kalle Niemitalo)
+  * fixed bug: lambda lists may contain symbols whose names start with
+    & but are not lambda-list-keywords; their occurrence triggers a
+    STYLE-WARNING.
   * optimization: rearranged the expansion of various defining macros
     so that each expands into only one top-level form in a
     :LOAD-TOPLEVEL context; this appears to decrease fasl sizes by
index 78b4379..5f5bdc0 100644 (file)
                              :required :rest)
                      state))
       (dolist (arg list)
-        (if (and (symbolp arg)
-                 (let ((name (symbol-name arg)))
-                   (and (plusp (length name))
-                        (char= (char name 0) #\&))))
+        (if (member arg sb!xc:lambda-list-keywords)
             (case arg
               (&optional
                (unless (eq state :required)
                  (compiler-error "misplaced &AUX in lambda list: ~S" list))
                (setq auxp t
                     state :aux))
-              ;; FIXME: I don't think ANSI says this is an error. (It
-              ;; should certainly be good for a STYLE-WARNING,
-              ;; though.)
-              (t
-               (compiler-error "unknown &KEYWORD in lambda list: ~S" arg)))
-            (case state
-              (:required (required arg))
-              (:optional (optional arg))
-              (:rest
-               (setq restp t
-                     rest arg
-                     state :post-rest))
-              (:more-context
-               (setq more-context arg
-                     state :more-count))
-              (:more-count
-               (setq more-count arg
-                     state :post-more))
-              (:key (keys arg))
-              (:aux (aux arg))
-              (t
-               (compiler-error "found garbage in lambda list when expecting ~
-                                a keyword: ~S"
-                               arg)))))
+              (t (bug "unknown LAMBDA-LIST-KEYWORD in lambda list: ~S." arg)))
+           (progn
+             (when (symbolp arg)
+               (let ((name (symbol-name arg)))
+                 (when (and (plusp (length name))
+                            (char= (char name 0) #\&))
+                   (style-warn
+                    "suspicious variable in lambda list: ~S." arg))))
+             (case state
+               (:required (required arg))
+               (:optional (optional arg))
+               (:rest
+                (setq restp t
+                      rest arg
+                      state :post-rest))
+               (:more-context
+                (setq more-context arg
+                      state :more-count))
+               (:more-count
+                (setq more-count arg
+                      state :post-more))
+               (:key (keys arg))
+               (:aux (aux arg))
+               (t
+                (compiler-error "found garbage in lambda list when expecting ~
+                                  a keyword: ~S"
+                                arg))))))
       (when (eq state :rest)
         (compiler-error "&REST without rest variable"))
 
index 1b7e38d..c07bc1b 100644 (file)
@@ -67,5 +67,9 @@
   (assert (= &key 3))
   (assert (null &allow-other-keys)))
 
+(let ((fn (lambda (&foo &rest &bar) (cons &foo &bar))))
+  (assert (equal (funcall fn 1) '(1)))
+  (assert (equal (funcall fn 1 2 3) '(1 2 3))))
+
 ;;; success
 (quit :unix-status 104)
index 488ac76..3cf2df8 100644 (file)
@@ -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".)
-"0.8.10.49"
+"0.8.10.50"