Fix element initialization for char arrays.

Closes #957.
This commit is contained in:
Alex Shinn 2024-05-23 10:47:36 +09:00
parent 4677cfb85b
commit ef4e450af7
2 changed files with 13 additions and 1 deletions

View file

@ -1303,6 +1303,15 @@
(test-error (array-packed? (test-error (array-packed?
(make-array (make-interval '#(1 2)) list list))) (make-array (make-interval '#(1 2)) list list)))
(test #\a
(let ((a (make-specialized-array (make-interval '#())
char-storage-class)))
(array-set! a #\a)
(array-ref a)))
(test #\a
(array-ref (make-specialized-array (make-interval '#())
char-storage-class #\a)))
;; all these are true, we'll have to see how to screw it up later. ;; all these are true, we'll have to see how to screw it up later.
;; (do ((i 0 (+ i 1))) ;; (do ((i 0 (+ i 1)))
;; ((= i tests)) ;; ((= i tests))

View file

@ -61,7 +61,10 @@
(define-storage-class char-storage-class (define-storage-class char-storage-class
(lambda (vec i) (integer->char (u32vector-ref vec i))) (lambda (vec i) (integer->char (u32vector-ref vec i)))
(lambda (vec i ch) (u32vector-set! vec i (char->integer ch))) (lambda (vec i ch) (u32vector-set! vec i (char->integer ch)))
char? make-u32vector u32vector-length 0) char?
(lambda (len init) (make-u32vector len (char->integer init)))
u32vector-length
#\space)
;; TODO: implement ;; TODO: implement
(define f8-storage-class #f) (define f8-storage-class #f)