~ chicken-core (chicken-5) fe4c184e20d358d2c9befb20a3d53c729b58fc86


commit fe4c184e20d358d2c9befb20a3d53c729b58fc86
Author:     Moritz Heidkamp <moritz@twoticketsplease.de>
AuthorDate: Wed Jan 2 22:02:10 2013 +0100
Commit:     felix <felix@call-with-current-continuation.org>
CommitDate: Thu Jan 3 11:47:01 2013 +0100

    Fix TO argument check in subvector procedure
    
    The subvector procedure checked its TO argument as if it was
    inclusive. However, its default value is the passed vector's length so
    it must be exclusive which also corresponds with the implementation. In
    effect, the erroneous check prevented producing a subvector including
    the given vector's last element. This patch changes the TO argument
    check to be exclusive and adds some test cases for the subvector
    procedure.
    
    Signed-off-by: felix <felix@call-with-current-continuation.org>

diff --git a/library.scm b/library.scm
index 5ed1e247..46cfe49f 100644
--- a/library.scm
+++ b/library.scm
@@ -1391,7 +1391,7 @@ EOF
 	 (j (or j len))
 	 (len2 (fx- j i)))
     (##sys#check-range i 0 len 'subvector)
-    (##sys#check-range j 0 len 'subvector)
+    (##sys#check-range j 0 (fx+ len 1) 'subvector)
     (let ((v2 (make-vector len2)))
       (do ((k 0 (fx+ k 1)))
 	  ((fx>= k len2) v2)
diff --git a/tests/library-tests.scm b/tests/library-tests.scm
index c385c1be..2d88321b 100644
--- a/tests/library-tests.scm
+++ b/tests/library-tests.scm
@@ -420,4 +420,10 @@
 
 ;;; message checks for invalid strings
 
-(assert-fail (##sys#message "123\x00456"))
\ No newline at end of file
+(assert-fail (##sys#message "123\x00456"))
+
+;;; vector procedures
+
+(assert (equal? '#(2 3) (subvector '#(1 2 3) 1)))
+(assert (equal? '#(2)   (subvector '#(1 2 3) 1 2)))
+(assert (equal? '#()    (subvector '#(1 2 3) 1 1)))
Trap