From 0051cc0532da9f68a0ba5db5c07ebee1c91ee4d8 Mon Sep 17 00:00:00 2001 From: Christophe Rhodes Date: Sat, 7 Jun 2003 11:01:58 +0000 Subject: [PATCH] 0.8.0.42: Quieten the compiler slightly for (LENGTH ) ... one of the transforms wants to constant-fold the above when is a 1d SIMPLE-ARRAY of known dimensions. However, the deftransform definition (with a simple-array type requirement) caused the compiler to complain when the argument was known to be a vector but not a simple-array. Instead, leave the type requirement for the transform open, and GIVE-UP-IR1-TRANSFORM (with no arguments => silence) if the argument isn't simple. ... write some tests for LENGTH on vectors --- src/compiler/array-tran.lisp | 5 +++-- tests/vector.pure.lisp | 13 +++++++++++-- version.lisp-expr | 2 +- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/compiler/array-tran.lisp b/src/compiler/array-tran.lisp index 3384b9f..724440d 100644 --- a/src/compiler/array-tran.lisp +++ b/src/compiler/array-tran.lisp @@ -509,9 +509,10 @@ ;;; If a simple array with known dimensions, then VECTOR-LENGTH is a ;;; compile-time constant. -(deftransform vector-length ((vector) ((simple-array * (*)))) +(deftransform vector-length ((vector)) (let ((vtype (continuation-type vector))) - (if (array-type-p vtype) + (if (and (array-type-p vtype) + (not (array-type-complexp vtype))) (let ((dim (first (array-type-dimensions vtype)))) (when (eq dim '*) (give-up-ir1-transform)) dim) diff --git a/tests/vector.pure.lisp b/tests/vector.pure.lisp index 9f60cca..210f7b6 100644 --- a/tests/vector.pure.lisp +++ b/tests/vector.pure.lisp @@ -16,10 +16,19 @@ (simple-u32 (make-array 50 :element-type '(unsigned-byte 32))) (simple-character (make-string 44)) - (complex-t (make-array 35 :fill-pointer 3)) + (complex-t (make-array 4 :fill-pointer 3)) (complex-u32 (make-array 88 + :adjustable t :element-type '(unsigned-byte 32))) (complex-character (make-array 14 :element-type 'character :fill-pointer t))) - (assert (= (length simple-t) 35))))) + (assert (= (length simple-t) 35)) + (assert (= (length simple-u32) 50)) + (assert (= (length simple-character) 44)) + (assert (= (length complex-t) 3)) + (assert (= (length complex-u32) 88)) + (assert (= (length complex-character) 14)) + (vector-push-extend #\a complex-t) + (assert (= (length complex-t) 4)) + (assert (raises-error? (vector-push-extend #\b simple-t)))))) diff --git a/version.lisp-expr b/version.lisp-expr index 60f15c1..2cffca4 100644 --- a/version.lisp-expr +++ b/version.lisp-expr @@ -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.0.41" +"0.8.0.42" -- 1.7.10.4