reader: immutable vectors and boxes from read-syntax

Closes #1745
This commit is contained in:
Matthew Flatt 2018-12-05 16:26:57 -07:00
parent 561fe7e2e7
commit fed7e5e95c
4 changed files with 21 additions and 4 deletions

View File

@ -522,6 +522,14 @@
(lambda (x) (and (vector? x) (eq? (vector-ref x 0) (vector-ref x 1))))
#2((1 2)))
;; Immutable vectors and boxes from `read-syntax`
(test #t immutable? (syntax-e (read-syntax #f (open-input-string "#(a b c)"))))
(test #t immutable? (syntax-e (read-syntax #f (open-input-string "#5(a b c)"))))
(test #t immutable? (syntax-e (read-syntax #f (open-input-string "#&a"))))
(test #f immutable? (read (open-input-string "#(a b c)")))
(test #f immutable? (read (open-input-string "#5(a b c)")))
(test #f immutable? (read (open-input-string "#&a")))
(define (graph-error-tests readstr graph-ok?)
(err/rt-test (readstr "#0#") exn:fail:read?)
(err/rt-test (readstr "#0=#0#") exn:fail:read?)

View File

@ -17,4 +17,7 @@
(reader-error in config #:due-to e #:end-pos open-end-pos
"expected an element for `~a&` box, found end-of-file"
dispatch-c))
(wrap (box e) in config #f))
(wrap (if (read-config-for-syntax? config)
(box-immutable e)
(box e))
in config #f))

View File

@ -75,7 +75,9 @@
(flvector-set! vec i e))])
vec])]))
(wrap vec
(wrap (if (read-config-for-syntax? config)
(vector->immutable-vector vec)
vec)
in
config
opener))

View File

@ -56009,7 +56009,11 @@ static const char *startup_source =
"(void)))"
"(let-values()(void))))))"
" vec_0))))))))))))"
"(wrap vec_0 in_0 config_0 opener_0))))))))))))))))"
"(wrap"
"(if(read-config-for-syntax? config_0)(vector->immutable-vector vec_0) vec_0)"
" in_0"
" config_0"
" opener_0))))))))))))))))"
"(define-values"
"(read-fixnum-or-flonum-vector)"
"(lambda(read-one_0 dispatch-c_0 c_0 c2_0 in_0 config_0)"
@ -58409,7 +58413,7 @@ static const char *startup_source =
" temp9_0"
"(list dispatch-c10_0))))"
"(void))"
"(wrap(box e_0) in_0 config_0 #f))))))))"
"(wrap(if(read-config-for-syntax? config_0)(box-immutable e_0)(box e_0)) in_0 config_0 #f))))))))"
"(define-values"
"(read-regexp)"
"(lambda(mode-c_0 accum-str_0 in_0 config_0)"