From 1fc800d85f2ecd18bbdaadc98c50c4336ce6af92 Mon Sep 17 00:00:00 2001 From: Kristian Lein-Mathisen Date: Thu, 13 Apr 2017 14:15:07 +0200 Subject: [PATCH] Fix a bug in srfi-4 this correctly uses s8vector-set! for the s8vector-ref's setter Signed-off-by: Peter Bex --- NEWS | 2 ++ srfi-4.scm | 2 +- tests/srfi-4-tests.scm | 7 ++++++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index b43e851..4713c83 100644 --- a/NEWS +++ b/NEWS @@ -10,6 +10,8 @@ interrupted by a signal, we now retry (thanks to Joerg Wittenberger). - char-ready? on string ports now also returns #t at EOF, as per R5RS; in other words, it always returns #t (thanks to Moritz Heidkamp) + - Unit srfi-4: Fixed typo that broke SRFI-17 generalised set! syntax + on s8vectors (thanks to Kristian Lein-Mathisen). - Build system - Fixed broken compilation on NetBSD, due to missing _NETBSD_SOURCE. diff --git a/srfi-4.scm b/srfi-4.scm index 69f58ba..89e62ae 100644 --- a/srfi-4.scm +++ b/srfi-4.scm @@ -189,7 +189,7 @@ EOF (let ((len (##core#inline "C_u_i_s8vector_length" x))) (check-range i 0 len 's8vector-ref) (##core#inline "C_u_i_s8vector_ref" x i))) - u8vector-set! + s8vector-set! "(s8vector-ref v i)")) (define u16vector-ref diff --git a/tests/srfi-4-tests.scm b/tests/srfi-4-tests.scm index 9daaa78..9af6c25 100644 --- a/tests/srfi-4-tests.scm +++ b/tests/srfi-4-tests.scm @@ -16,12 +16,17 @@ (assert (= 100 (,(conc "vector-ref") x 0))) (assert (,(conc "vector?") x)) (assert (number-vector? x)) + ;; Test direct setter and ref (,(conc "vector-set!") x 1 99) (assert (= 99 (,(conc "vector-ref") x 1))) + ;; Test SRFI-17 generalised set! and ref + (set! (,(conc "vector-ref") x 0) 127) + (assert (= 127 (,(conc "vector-ref") x 0))) + ;; Ensure length is okay (assert (= 2 (,(conc "vector-length") x))) (assert (every = - '(100 99) + '(127 99) (,(conc "vector->list") x)))))))) (test1 u8) -- 2.1.4