schemify: ensure that deserialized constants are immutable
Closes #2394
This commit is contained in:
parent
669e51768d
commit
744d440ab9
|
@ -2185,6 +2185,26 @@
|
|||
(test 'cons exn:fail:contract:variable-id e)
|
||||
(test #t regexp-match? #rx"^cons: " (exn-message e)))
|
||||
|
||||
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; Check immutability after saving and restoring quoted constants
|
||||
|
||||
(let ([m `(module defines-immutable-objects racket/base
|
||||
(provide objs)
|
||||
(define objs
|
||||
'(#"x"
|
||||
"x"
|
||||
#()
|
||||
#(1)
|
||||
#(#:x)
|
||||
#(#"x")
|
||||
#&1
|
||||
#&#:x
|
||||
#&#"x"
|
||||
#hasheq((a . b)))))])
|
||||
(define c (compile m))
|
||||
(eval c)
|
||||
(test #t andmap immutable? (dynamic-require ''defines-immutable-objects 'objs)))
|
||||
|
||||
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(report-errs)
|
||||
|
|
|
@ -181,16 +181,14 @@
|
|||
`(cons ,a ,d))))]
|
||||
[(vector? q)
|
||||
(let ([args (map make-construct (vector->list q))])
|
||||
(if (and (andmap quote? args)
|
||||
`(vector->immutable-vector
|
||||
,(if (and (andmap quote? args)
|
||||
(not (impersonator? q)))
|
||||
`(quote ,q)
|
||||
`(vector ,@args)))]
|
||||
`(vector ,@args))))]
|
||||
[(box? q)
|
||||
(let ([arg (make-construct (unbox q))])
|
||||
(if (and (quote? arg)
|
||||
(not (impersonator? q)))
|
||||
`(quote ,q)
|
||||
`(box ,arg)))]
|
||||
`(box-immutable ,arg))]
|
||||
[(prefab-struct-key q)
|
||||
=> (lambda (key)
|
||||
`(make-prefab-struct ',key ,@(map make-construct
|
||||
|
|
Loading…
Reference in New Issue
Block a user