0.7.9.3:
authorChristophe Rhodes <csr21@cam.ac.uk>
Sat, 26 Oct 2002 11:22:51 +0000 (11:22 +0000)
committerChristophe Rhodes <csr21@cam.ac.uk>
Sat, 26 Oct 2002 11:22:51 +0000 (11:22 +0000)
Make DEFGENERIC reject forbidden declarations

src/pcl/boot.lisp
tests/clos.impure.lisp
version.lisp-expr

index c2184b3..0d67f60 100644 (file)
@@ -171,6 +171,24 @@ bootstrapping.
          (let ((car-option (car option)))
            (case car-option
              (declare
+              (when (and
+                     (consp (cadr option))
+                     (member (first (cadr option))
+                             ;; FIXME: this list is slightly weird.
+                             ;; ANSI (on the DEFGENERIC page) in one
+                             ;; place allows only OPTIMIZE; in
+                             ;; another place gives this list of
+                             ;; disallowed declaration specifiers.
+                             ;; This seems to be the only place where
+                             ;; the FUNCTION declaration is
+                             ;; mentioned; TYPE seems to be missing.
+                             ;; Very strange.  -- CSR, 2002-10-21
+                             '(declaration ftype function
+                               inline notinline special)))
+                (error 'simple-program-error
+                       :format-control "The declaration specifier ~S ~
+                                         is not allowed inside DEFGENERIC."
+                       :format-arguments (list (cadr option))))
               (push (cdr option) (initarg :declarations)))
              ((:argument-precedence-order :method-combination)
               (if (initarg car-option)
index f5062b7..ef478bf 100644 (file)
   (defmethod documentation ((x (eql '+)) y) "WRONG")
   (assert (string= (documentation '+ 'function) answer)))
 \f
+;;; only certain declarations are permitted in DEFGENERIC
+(macrolet ((assert-program-error (form)
+            `(multiple-value-bind (value error)
+                 (ignore-errors ,form)
+               (assert (null value))
+               (assert (typep error 'program-error)))))
+  (assert-program-error (defgeneric bogus-declaration (x)
+                         (declare (special y))))
+  (assert-program-error (defgeneric bogus-declaration2 (x)
+                         (declare (notinline concatenate)))))
+\f
 ;;;; success
 
 (sb-ext:quit :unix-status 104)
index 33b868b..130d6ed 100644 (file)
@@ -18,4 +18,4 @@
 ;;; versions, especially for internal versions off the main CVS
 ;;; branch, it gets hairier, e.g. "0.pre7.14.flaky4.13".)
 
-"0.7.9.2"
+"0.7.9.3"