From 7e696132caef69397b75ca74d0d0de96b20029a4 Mon Sep 17 00:00:00 2001 From: Anish Athalye Date: Sun, 16 Oct 2022 20:54:51 -0400 Subject: [PATCH] Make evaluate preserve vector immutability (#244) Prior to this patch, the following returned an immutable vector: (define empty-model (solve (void))) (evaluate (vector-immutable 1) empty-model) However, the following returned a _mutable_ vector, even though `evaluate` is given an immutable vector (containing no symbolics): (define-symbolic* b boolean?) (define model (solve (assert b))) (evaluate (vector-immutable 1) model) With this patch, both examples above return an immutable vector. --- rosette/query/eval.rkt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/rosette/query/eval.rkt b/rosette/query/eval.rkt index 96abbbd8..bf20a131 100644 --- a/rosette/query/eval.rkt +++ b/rosette/query/eval.rkt @@ -47,7 +47,10 @@ [(cons x y) (cons (eval-rec x sol cache) (eval-rec y sol cache))] [(? vector?) - (for/vector #:length (vector-length expr) ([e expr]) (eval-rec e sol cache))] + (let ([v (for/vector #:length (vector-length expr) ([e expr]) (eval-rec e sol cache))]) + (if (immutable? expr) + (vector->immutable-vector v) + v))] [(? box?) ((if (immutable? expr) box-immutable box) (eval-rec (unbox expr) sol cache))] [(? typed?)