0.8.2.4:
authorChristophe Rhodes <csr21@cam.ac.uk>
Sun, 27 Jul 2003 15:24:11 +0000 (15:24 +0000)
committerChristophe Rhodes <csr21@cam.ac.uk>
Sun, 27 Jul 2003 15:24:11 +0000 (15:24 +0000)
As reported by pfdietz sbcl-devel 2003-07-27, MAKE-SEQUENCE,
MERGE and CONCATENATE weren't inferring their return type
aggressively enough when given VECTOR as the type specifier.

src/code/early-type.lisp
src/compiler/knownfun.lisp
tests/compiler.pure.lisp
version.lisp-expr

index bbb75ba..6679a42 100644 (file)
                     :enumerable enumerable))
 
 ;;; An ARRAY-TYPE is used to represent any array type, including
-;;; things such as SIMPLE-STRING.
+;;; things such as SIMPLE-BASE-STRING.
 (defstruct (array-type (:include ctype
                                 (class-info (type-class-or-lose 'array)))
                        (:constructor %make-array-type)
index d28f79e..8d96138 100644 (file)
 
 ;;; Derive the type to be the type specifier which is the Nth arg,
 ;;; with the additional restriptions noted in the CLHS for STRING and
-;;; SIMPLE-STRING.
+;;; SIMPLE-STRING, defined to specialize on CHARACTER, and for VECTOR
+;;; (under the page for MAKE-SEQUENCE).
 (defun creation-result-type-specifier-nth-arg (n)
   (lambda (call)
     (declare (type combination call))
               (declare (ignore simple-string))
               (careful-specifier-type
                `(simple-array character ,@(if size (list size) '((*)))))))
-           (t (careful-specifier-type specifier))))))))
+           (t
+            (let ((ctype (careful-specifier-type specifier)))
+              (if (and (array-type-p ctype)
+                       (eq (array-type-specialized-element-type ctype)
+                           *wild-type*))
+                  ;; I don't think I'm allowed to modify what I get
+                  ;; back from SPECIFIER-TYPE; it is, after all,
+                  ;; cached.  Better copy it, then.
+                  (let ((real-ctype (copy-structure ctype)))
+                    (setf (array-type-element-type real-ctype)
+                          *universal-type*
+                          (array-type-specialized-element-type real-ctype)
+                          *universal-type*)
+                    real-ctype)
+                  ctype)))))))))
 
 (/show0 "knownfun.lisp end of file")
index d2e81c8..5066830 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)))
                 (declare (type (simple-array (simple-string 3) (5)) x))
                 (aref (aref x 0) 0))))
 
-;; compiler failure
+;;; compiler failure
 (let ((f (compile nil '(lambda (x) (typep x '(not (member 0d0)))))))
   (assert (funcall f 1d0)))
 
               (let ((y (* x pi)))
                 (atan y y))))
 
-;; bogus optimization of BIT-NOT
+;;; bogus optimization of BIT-NOT
 (multiple-value-bind (result x)
     (eval '(let ((x (eval #*1001)))
             (declare (optimize (speed 2) (space 3))
             (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))))
index 865410d..9d2518b 100644 (file)
@@ -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.2.3"
+"0.8.2.4"