From 64c4aa20ab47549c662d15795cb2d284943083d4 Mon Sep 17 00:00:00 2001 From: Stas Boukarev Date: Sat, 23 Apr 2016 20:49:17 +0300 Subject: [PATCH] Fix REVERSE on vectors with fill-pointers. --- src/code/seq.lisp | 2 +- tests/array.pure.lisp | 18 +++++++++++++----- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/code/seq.lisp b/src/code/seq.lisp index 6d4921024..cbc569d15 100644 --- a/src/code/seq.lisp +++ b/src/code/seq.lisp @@ -795,7 +795,7 @@ many elements are copied." (defun reverse-word-specialized-vector (from to end) (declare (vector from)) - (do ((length (length from)) + (do ((length (length to)) (left-index 0 (1+ left-index)) (right-index end)) ((= left-index length)) diff --git a/tests/array.pure.lisp b/tests/array.pure.lisp index 24441e7da..63e476f6f 100644 --- a/tests/array.pure.lisp +++ b/tests/array.pure.lisp @@ -93,11 +93,19 @@ ;;; Following refactoring of sequence functions to detect bad type ;;; specifiers, REVERSE was left broken on vectors with fill pointers. -(let ((a (make-array 10 - :fill-pointer 5 - :element-type 'character - :initial-contents "abcdefghij"))) - (assert (string= (reverse a) "edcba"))) +(with-test (:name :reverse-fill-pointer.string) + (let ((a (make-array 10 + :fill-pointer 5 + :element-type 'character + :initial-contents "abcdefghij"))) + (assert (string= (reverse a) "edcba")))) + +(with-test (:name :reverse-fill-pointer.fixnum) + (let ((a (make-array 10 + :fill-pointer 6 + :element-type 'fixnum + :initial-contents '(0 1 2 3 4 5 7 8 9 10)))) + (assert (equalp (reverse a) #(5 4 3 2 1 0))))) ;;; ARRAY-IN-BOUNDS-P should work when given non-INDEXes as its ;;; subscripts (and return NIL, of course) -- 2.11.4.GIT