From 3d1f783a15fa74c4cb7cd7065a57ed74904eecbd Mon Sep 17 00:00:00 2001 From: Christophe Rhodes Date: Mon, 24 May 2004 13:38:52 +0000 Subject: [PATCH] 0.8.10.50: Allow &FOO in lambda lists, with a style-warning, rather than a full error (as per FIXME and #lisp IRC) --- NEWS | 3 ++ src/compiler/parse-lambda-list.lisp | 56 +++++++++++++++++------------------ tests/smoke.impure.lisp | 4 +++ version.lisp-expr | 2 +- 4 files changed, 36 insertions(+), 29 deletions(-) diff --git a/NEWS b/NEWS index e014912..dcd278d 100644 --- 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 diff --git a/src/compiler/parse-lambda-list.lisp b/src/compiler/parse-lambda-list.lisp index 78b4379..5f5bdc0 100644 --- a/src/compiler/parse-lambda-list.lisp +++ b/src/compiler/parse-lambda-list.lisp @@ -64,10 +64,7 @@ :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) @@ -101,30 +98,33 @@ (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")) diff --git a/tests/smoke.impure.lisp b/tests/smoke.impure.lisp index 1b7e38d..c07bc1b 100644 --- a/tests/smoke.impure.lisp +++ b/tests/smoke.impure.lisp @@ -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) diff --git a/version.lisp-expr b/version.lisp-expr index 488ac76..3cf2df8 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".) -"0.8.10.49" +"0.8.10.50" -- 1.7.10.4