lloda pushed a commit to branch wip-exception-truncate in repository guile.
commit fd9ce3989fca22c175350489e6922ad25d4b6cdd Author: Daniel Llorens <ll...@sarc.name> AuthorDate: Fri Feb 7 11:11:26 2020 +0100 Note on modifying literal vectors This has been for compiled expressions since 7ed54fd36d2e381aa46ef8a7d2fc13a6776b573a, but apparently not yet for the evaluator (?) --- doc/ref/api-data.texi | 7 +++---- test-suite/tests/vectors.test | 16 ++++++++-------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/doc/ref/api-data.texi b/doc/ref/api-data.texi index 41d4f73..77bb854 100644 --- a/doc/ref/api-data.texi +++ b/doc/ref/api-data.texi @@ -6356,10 +6356,9 @@ A vector created by one of the dynamic vector constructor procedures (@pxref{Vector Creation}) can be modified using the following procedures. -@emph{NOTE:} According to R5RS, it is an error to use any of these -procedures on a literally read vector, because such vectors should be -considered as constants. Currently, however, Guile does not detect this -error. +@emph{NOTE:} Following R5RS, it is an error to use any of these +procedures on a literally read vector, because such vectors are +considered as constants. @rnindex vector-set! @deffn {Scheme Procedure} vector-set! vec k obj diff --git a/test-suite/tests/vectors.test b/test-suite/tests/vectors.test index 97b3f18..e47baaf 100644 --- a/test-suite/tests/vectors.test +++ b/test-suite/tests/vectors.test @@ -17,18 +17,18 @@ ;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA (define-module (test-suite vectors) - :use-module (test-suite lib)) + :use-module (test-suite lib) + #:autoload (system base compile) (compile)) -;; FIXME: As soon as guile supports immutable vectors, this has to be -;; replaced with the appropriate error type and message. -(define exception:immutable-vector - (cons 'some-error-type "^trying to modify an immutable vector")) +(with-test-prefix "vector-set! (compile)" + (pass-if-exception "vector constant" exception:wrong-type-arg + (compile '(vector-set! '#(1 2 3) 0 4) #:to 'value + #:env (current-module)))) -(with-test-prefix "vector-set!" +(with-test-prefix "vector-set! (eval)" - (expect-fail-exception "vector constant" - exception:immutable-vector + (expect-fail-exception "vector constant" exception:wrong-type-arg (vector-set! '#(1 2 3) 0 4))) (with-test-prefix "vector->list"