From e3b6a3e3ee72b4bee3909a1876b33bd3bf6fa596 Mon Sep 17 00:00:00 2001 From: Stas Boukarev Date: Sun, 17 Mar 2013 12:53:47 +0400 Subject: [PATCH] make-array transform error on unknown element-type. Check for the type to be known, otherwise give up transforming. Based on a patch by James Kalenius. Fixes lp#1156095. --- NEWS | 3 +++ src/compiler/array-tran.lisp | 11 +++++++---- tests/array.pure.lisp | 10 ++++++++++ 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/NEWS b/NEWS index 848ea8a..2207042 100644 --- 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 diff --git a/src/compiler/array-tran.lisp b/src/compiler/array-tran.lisp index 02c5c37..baeb93b 100644 --- a/src/compiler/array-tran.lisp +++ b/src/compiler/array-tran.lisp @@ -609,7 +609,12 @@ (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" @@ -626,9 +631,7 @@ (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 '*)) diff --git a/tests/array.pure.lisp b/tests/array.pure.lisp index 442358e..ba823a0 100644 --- a/tests/array.pure.lisp +++ b/tests/array.pure.lisp @@ -288,3 +288,13 @@ (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)))) -- 1.7.10.4