ignore non-function FTYPEs
authorNikodemus Siivola <nikodemus@random-state.net>
Wed, 17 Aug 2011 09:28:29 +0000 (12:28 +0300)
committerNikodemus Siivola <nikodemus@random-state.net>
Mon, 22 Aug 2011 11:17:38 +0000 (14:17 +0300)
  Fixes lp#738464.

  Give a style-warning and ignore the bad type.

src/compiler/ir1tran.lisp
tests/compiler.pure.lisp

index 984db31..8a4cf1a 100644 (file)
   (declare (type list names fvars)
            (type lexenv res))
   (let ((type (compiler-specifier-type spec)))
+    (unless (csubtypep type (specifier-type 'function))
+      (compiler-style-warn "ignoring declared FTYPE: ~S (not a function type)" spec)
+      (return-from process-ftype-decl res))
     (collect ((res nil cons))
       (dolist (name names)
         (when (fboundp name)
index fa8da25..fff0ec4 100644 (file)
          (fun (compile nil `(lambda (p1 p2)
                               (schar (the (eql ,foo) p1) p2)))))
     (assert (eql #\f (funcall fun foo 0)))))
+
+(with-test (:name :bug-738464)
+  (multiple-value-bind (fun warn fail)
+      (compile nil `(lambda ()
+                      (flet ((foo () 42))
+                        (declare (ftype non-function-type foo))
+                        (foo))))
+    (assert (eql 42 (funcall fun)))
+    (assert (and warn (not fail)))))