From c03cebe05df9c538f85d30aa5f22c5ca1f3a8283 Mon Sep 17 00:00:00 2001 From: Christophe Rhodes Date: Sun, 26 Jan 2003 17:25:14 +0000 Subject: [PATCH] 0.7.12.2: Allow ARRAY-IN-BOUNDS-P to take arbitrary integers as arguments without signalling a TYPE-ERROR on non-INDEXes (misbehaviour found by Paul Dietz' test suite) --- NEWS | 5 +++++ src/code/array.lisp | 4 ++-- src/compiler/fndb.lisp | 2 +- tests/array.pure.lisp | 9 +++++++++ version.lisp-expr | 2 +- 5 files changed, 18 insertions(+), 4 deletions(-) diff --git a/NEWS b/NEWS index 755c12e..c4182e0 100644 --- a/NEWS +++ b/NEWS @@ -1501,6 +1501,11 @@ changes in sbcl-0.7.12 relative to sbcl-0.7.11: not cause a type error; ** CONSTANTP now returns true for all self-evaluating objects. +changes in sbcl-0.7.13 relative to sbcl-0.7.12: + * fixed some bugs revealed by Paul Dietz' test suite: + ** ARRAY-IN-BOUNDS-P now allows arbitrary integers as arguments, + not just nonnegative fixnums; + planned incompatible changes in 0.7.x: * (not done yet, but planned:) When the profiling interface settles down, maybe in 0.7.x, maybe later, it might impact TRACE. They both diff --git a/src/code/array.lisp b/src/code/array.lisp index 10f81e8..eb4c346 100644 --- a/src/code/array.lisp +++ b/src/code/array.lisp @@ -375,7 +375,7 @@ (declare (list subs) (fixnum axis chunk-size result)) (let ((index (car subs)) (dim (%array-dimension array axis))) - (declare (fixnum index dim)) + (declare (fixnum dim)) (unless (< -1 index dim) (if invalid-index-error-p (error 'simple-type-error @@ -384,7 +384,7 @@ :datum index :expected-type `(integer 0 (,dim))) (return-from %array-row-major-index nil))) - (incf result (* chunk-size index)) + (incf result (* chunk-size (the fixnum index))) (setf chunk-size (* chunk-size dim)))) (let ((index (first subscripts)) (length (length (the (simple-array * (*)) array)))) diff --git a/src/compiler/fndb.lisp b/src/compiler/fndb.lisp index fb22c96..6f9eaa7 100644 --- a/src/compiler/fndb.lisp +++ b/src/compiler/fndb.lisp @@ -791,7 +791,7 @@ (defknown array-rank (array) array-rank (foldable flushable)) (defknown array-dimension (array array-rank) index (foldable flushable)) (defknown array-dimensions (array) list (foldable flushable)) -(defknown array-in-bounds-p (array &rest index) boolean (foldable flushable)) +(defknown array-in-bounds-p (array &rest integer) boolean (foldable flushable)) (defknown array-row-major-index (array &rest index) array-total-size (foldable flushable)) (defknown array-total-size (array) array-total-size (foldable flushable)) diff --git a/tests/array.pure.lisp b/tests/array.pure.lisp index eb44817..2a8fac0 100644 --- a/tests/array.pure.lisp +++ b/tests/array.pure.lisp @@ -87,3 +87,12 @@ :element-type 'character :initial-contents "abcdefghij"))) (assert (string= (reverse a) "edcba"))) + +;;; ARRAY-IN-BOUNDS-P should work when given non-INDEXes as its +;;; subscripts (and return NIL, of course) +(let ((a (make-array 10 :fill-pointer 5))) + (assert (not (array-in-bounds-p a -1))) + (assert (array-in-bounds-p a 3)) + (assert (array-in-bounds-p a 7)) + (assert (not (array-in-bounds-p a 11))) + (assert (not (array-in-bounds-p a (1+ most-positive-fixnum))))) diff --git a/version.lisp-expr b/version.lisp-expr index 41e148f..d0acfe4 100644 --- a/version.lisp-expr +++ b/version.lisp-expr @@ -18,4 +18,4 @@ ;;; versions, especially for internal versions off the main CVS ;;; branch, it gets hairier, e.g. "0.pre7.14.flaky4.13".) -"0.7.12.1" +"0.7.12.2" -- 1.7.10.4