Fix make-array transforms. master
authorStas Boukarev <stassats@gmail.com>
Sun, 5 Jan 2014 09:54:19 +0000 (13:54 +0400)
committerStas Boukarev <stassats@gmail.com>
Sun, 5 Jan 2014 10:00:54 +0000 (14:00 +0400)
Don't call UPGRADED-ARRAY-ELEMENT-TYPE on types without checking that
they don't contain unknown types (i.e., intersections or unions
containing unknown-type), since U-A-E-T now signals errors for these.

Reported by Bart Botta.

package-data-list.lisp-expr
src/code/late-type.lisp
src/compiler/array-tran.lisp
src/compiler/generic/vm-type.lisp
tests/compiler.pure.lisp

index 72bf994..612236d 100644 (file)
@@ -1351,6 +1351,7 @@ is a good idea, but see SB-SYS re. blurring of boundaries."
                "%COMPARE-AND-SWAP-SYMBOL-VALUE"
                "%CONCATENATE-TO-BASE-STRING"
                "%CONCATENATE-TO-STRING"
+               "CONTAINS-UNKNOWN-TYPE-P"
                "%COS" "%COS-QUICK"
                "%COSH" "%DATA-VECTOR-AND-INDEX" "%DEPOSIT-FIELD"
                "%DOUBLE-FLOAT" "%DPB" "%EQL"
index 04a93f2..8190493 100644 (file)
         (funcall method type2 type1)
         (hierarchical-intersection2 type1 type2))))
 
+(defun contains-unknown-type-p (ctype)
+  (cond ((unknown-type-p ctype) t)
+        ((intersection-type-p ctype)
+         (some #'contains-unknown-type-p (intersection-type-types ctype)))
+        ((union-type-p ctype)
+         (some #'contains-unknown-type-p (union-type-types ctype)))))
+
 ;;; This is used by !DEFINE-SUPERCLASSES to define the SUBTYPE-ARG1
 ;;; method. INFO is a list of conses
 ;;;   (SUPERCLASS-CLASS . {GUARD-TYPE-SPECIFIER | NIL}).
index c44afb4..bc2fc02 100644 (file)
                          (let ((ctype (careful-specifier-type
                                        (lvar-value element-type))))
                            (cond
-                             ((or (null ctype) (unknown-type-p ctype)) '*)
+                             ((or (null ctype) (contains-unknown-type-p ctype)) '*)
                              (t (sb!xc:upgraded-array-element-type
                                  (lvar-value element-type))))))
                         (t
           (element-type-ctype (and (constant-lvar-p element-type)
                                    (ir1-transform-specifier-type
                                     (lvar-value element-type)))))
-      (when (unknown-type-p element-type-ctype)
+      (when (contains-unknown-type-p element-type-ctype)
         (give-up-ir1-transform))
       (unless (every #'integerp dims)
         (give-up-ir1-transform
index 9d0a031..5c78b2b 100644 (file)
     (double-float 'double-float)
     #!+long-float (long-float 'long-float)))
 
-(defun contains-unknown-type-p (ctype)
-  (cond ((unknown-type-p ctype) t)
-        ((intersection-type-p ctype)
-         (some #'contains-unknown-type-p (intersection-type-types ctype)))
-        ((union-type-p ctype)
-         (some #'contains-unknown-type-p (union-type-types ctype)))))
-
 ;;; This function is called when the type code wants to find out how
 ;;; an array will actually be implemented. We set the
 ;;; SPECIALIZED-ELEMENT-TYPE to correspond to the actual
index 1fd9166..604e176 100644 (file)
 
 (with-test (:name :upgraded-array-element-type-undefined-type)
   (raises-error? (upgraded-array-element-type 'an-undefined-type))
-  (raises-error? (upgraded-array-element-type '(and fixnum an-undefined-type))))
+  (raises-error? (upgraded-array-element-type '(and fixnum an-undefined-type)))
+  (compile nil '(lambda ()
+                 (make-array 10
+                  :element-type '(or null an-undefined-type))))
+  (compile nil '(lambda ()
+                 (make-array '(10 10)
+                  :element-type '(or null an-undefined-type)))))