make-array transform error on unknown element-type.
authorStas Boukarev <stassats@gmail.com>
Sun, 17 Mar 2013 08:53:47 +0000 (12:53 +0400)
committerStas Boukarev <stassats@gmail.com>
Sun, 17 Mar 2013 08:53:47 +0000 (12:53 +0400)
Check for the type to be known, otherwise give up transforming.
Based on a patch by James Kalenius.
Fixes lp#1156095.

NEWS
src/compiler/array-tran.lisp
tests/array.pure.lisp

diff --git a/NEWS b/NEWS
index 848ea8a..2207042 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -17,6 +17,9 @@ changes relative to sbcl-1.1.5:
     (regression since 1.0.37.44).
   * bug fix: accessing &MORE (stack allocated &REST) arguments checks bounds.
     (lp#1154946)
+  * bug fix: compiling make-array no longer signals an error when the
+    element-type is an uknown type, a warning is issued instead.
+    Thanks to James Kalenius (lp#1156095)
 
 changes in sbcl-1.1.5 relative to sbcl-1.1.4:
   * minor incompatible change: SB-SPROF:WITH-PROFILING no longer loops
index 02c5c37..baeb93b 100644 (file)
     (unless (constant-lvar-p dims)
       (give-up-ir1-transform
        "The dimension list is not constant; cannot open code array creation."))
-    (let ((dims (lvar-value dims)))
+    (let ((dims (lvar-value dims))
+          (element-type-ctype (and (constant-lvar-p element-type)
+                                   (ir1-transform-specifier-type
+                                    (lvar-value element-type)))))
+      (when (unknown-type-p element-type-ctype)
+        (give-up-ir1-transform))
       (unless (every #'integerp dims)
         (give-up-ir1-transform
          "The dimension list contains something other than an integer: ~S"
                  (rank (length dims))
                  (spec `(simple-array
                          ,(cond ((null element-type) t)
-                                ((and (constant-lvar-p element-type)
-                                      (ir1-transform-specifier-type
-                                       (lvar-value element-type)))
+                                (element-type-ctype
                                  (sb!xc:upgraded-array-element-type
                                   (lvar-value element-type)))
                                 (t '*))
index 442358e..ba823a0 100644 (file)
   (let ((a (make-array 1 :initial-element 5)))
     (assert (equalp (adjust-array a 2 :initial-element 10)
                     #(5 10)))))
+
+(with-test (:name (make-array-transform-unknown-type :bug-1156095))
+  (assert
+   (handler-case
+       (compile nil `(lambda () (make-array '(1 2)
+                                            :element-type ',(gensym))))
+     (style-warning ()
+       t)
+     (:no-error (&rest args)
+       nil))))