0.8.3.18:
[sbcl.git] / tests / compiler.pure.lisp
index 64f425e..948d419 100644 (file)
                                 (declare (notinline mapcar))
                                 (1+ (mapcar #'print '(1 2 3)))))))
 
-;; bug found by Paul Dietz: (SETF AREF) for bit vectors with constant
-;; index was effectless
+;;; bug found by Paul Dietz: (SETF AREF) for bit vectors with constant
+;;; index was effectless
 (let ((f (compile nil '(lambda (a v)
                         (declare (type simple-bit-vector a) (type bit v))
                         (declare (optimize (speed 3) (safety 0)))
   (compile nil '(lambda (x)
                 (declare (type (simple-array (simple-string 3) (5)) x))
                 (aref (aref x 0) 0))))
+
+;;; compiler failure
+(let ((f (compile nil '(lambda (x) (typep x '(not (member 0d0)))))))
+  (assert (funcall f 1d0)))
+
+(compile nil '(lambda (x)
+              (declare (double-float x))
+              (let ((y (* x pi)))
+                (atan y y))))
+
+;;; bogus optimization of BIT-NOT
+(multiple-value-bind (result x)
+    (eval '(let ((x (eval #*1001)))
+            (declare (optimize (speed 2) (space 3))
+                     (type (bit-vector) x))
+            (values (bit-not x nil) x)))
+  (assert (equal x #*1001))
+  (assert (equal result #*0110)))
+
+;;; the VECTOR type in CONCATENATE/MERGE/MAKE-SEQUENCE means (VECTOR T).
+(handler-bind ((sb-ext:compiler-note #'error))
+  (assert (equalp (funcall
+                  (compile
+                   nil
+                   '(lambda ()
+                     (let ((x (make-sequence 'vector 10 :initial-element 'a)))
+                       (setf (aref x 4) 'b)
+                       x))))
+                 #(a a a a b a a a a a))))
+
+;;; this is not a check for a bug, but rather a test of compiler
+;;; quality
+(dolist (type '((integer 0 *)           ; upper bound
+                (real (-1) *)
+                float                   ; class
+                (real * (-10))          ; lower bound
+                ))
+  (assert (nth-value
+           1 (compile nil
+                      `(lambda (n)
+                         (declare (optimize (speed 3) (compilation-speed 0)))
+                         (loop for i from 1 to (the (integer -17 10) n) by 2
+                               collect (when (> (random 10) 5)
+                                         (the ,type (- i 11)))))))))
+
+;;; bug 278b
+;;;
+;;; We suppose that INTEGER arithmetic cannot be efficient, and the
+;;; compiler has an optimized VOP for +; so this code should cause an
+;;; efficiency note.
+(assert (eq (block nil
+              (handler-case
+                  (compile nil '(lambda (i)
+                                 (declare (optimize speed))
+                                 (declare (type integer i))
+                                 (+ i 2)))
+                (sb-ext:compiler-note (c) (return :good))))
+            :good))