fasl: find shared values in hash tables. (#2371)

Also, add test to check sharing of uninterned symbols.
This commit is contained in:
Sam Tobin-Hochstadt 2018-11-14 18:45:54 -05:00 committed by GitHub
parent c51616ecfd
commit cf34c22380
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 0 deletions

View File

@ -54,6 +54,14 @@
(test #t eq? u (car s-exp))
(test #t eq? u (cadr s-exp)))
(let* ([u (string->uninterned-symbol "unread")])
(define vs-exp (vector-ref (fasl->s-exp (s-exp->fasl (vector (cons u u)))) 0))
;; these are not `eq?` to the original symbol, but are `eq? to each other
(test #t eq? (car vs-exp) (cdr vs-exp))
(define hs-exp (hash-ref (fasl->s-exp (s-exp->fasl (hasheq 0 (cons u u)))) 0))
(test #t eq? (car hs-exp) (cdr hs-exp)))
;; check uses datum-intern-literal:
(test #t eq? "hello" (fasl->s-exp (s-exp->fasl "hello")))
(test #t eq? #"hello" (fasl->s-exp (s-exp->fasl #"hello")))

View File

@ -122,6 +122,9 @@
[(vector? v)
(for ([e (in-vector v)])
(loop e))]
[(hash? v)
(for ([(k v) (in-hash v)])
(loop k) (loop v))]
[(box? v)
(loop (unbox v))]
[(prefab-struct-key v)