X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fcompiler%2Fparse-lambda-list.lisp;h=6109cbd082d6f98a16df99d21cf82a57ae76f0d1;hb=5ecef987f3847ed5de8c03f66ef9d8ab468af993;hp=78b4379e4bd5f27d763232b0a1b5434b99d2a84e;hpb=9489abab7f981b8eea2aec8a883f2eb48d4cb138;p=sbcl.git diff --git a/src/compiler/parse-lambda-list.lisp b/src/compiler/parse-lambda-list.lisp index 78b4379..6109cbd 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) @@ -87,6 +84,10 @@ (unless (member state '(:required :optional :post-rest :post-more)) (compiler-error "misplaced &KEY in lambda list: ~S" list)) + #-sb-xc-host + (when (optional) + (compiler-style-warn + "&OPTIONAL and &KEY found in the same lambda list: ~S" list)) (setq keyp t state :key)) (&allow-other-keys @@ -99,32 +100,37 @@ (&aux (when (member state '(:rest :more-context :more-count)) (compiler-error "misplaced &AUX in lambda list: ~S" list)) + (when auxp + (compiler-error "multiple &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"))