fix printing of prefabs with print-unreadable is #f

Closes #3827
This commit is contained in:
Matthew Flatt 2021-05-08 09:57:14 -06:00
parent bb462baf30
commit d14c454096
4 changed files with 9 additions and 3 deletions

View File

@ -107,6 +107,9 @@
(ptest "#<a>" (a 1 2))
(ptest "(b 1 2)" (b 1 2))
(ptest "'#s(c 1 2)" (c 1 2))
(test "#s(c 1 2)" 'prefab
(parameterize ([print-unreadable #f])
(format "~s" (c 1 2))))
(let ([s (b 1 2)])
(ptest "(list (cons (b 1 2) 0) (cons (b 1 2) 0))" (list (cons s 0) (cons s 0))))

View File

@ -2276,7 +2276,7 @@ print(Scheme_Object *obj, int notdisplay, int compact, Scheme_Hash_Table *ht,
vec = scheme_struct_to_vector(obj, (notdisplay >= 3) ? qq_ellipses : NULL, pp->inspector);
SCHEME_VEC_ELS(vec)[0] = prefab;
print_vector(vec, notdisplay, compact, ht, mt, pp, 1);
} else if (compact || !pp->print_unreadable) {
} else if (compact || (!pp->print_unreadable && !SCHEME_PREFABP(obj))) {
cannot_print(pp, notdisplay, obj, ht, compact);
} else if (scheme_is_writable_struct(obj)) {
if (notdisplay == 3) {

View File

@ -22081,8 +22081,10 @@
(config-get
config_0
1/print-unreadable))
(not
(|#%app| printable-regexp? v_0))
(if (not (prefab-struct-key v_0))
(not
(|#%app| printable-regexp? v_0))
#f)
#f)
#f)
(fail-unreadable who_0 v_0)

View File

@ -299,6 +299,7 @@
(write-string/max "#<hash>" o max-length)])]
[(and (eq? mode WRITE-MODE)
(not (config-get config print-unreadable))
(not (prefab-struct-key v))
;; Regexps are a special case: custom writers that produce readable input
(not (printable-regexp? v)))
(fail-unreadable who v)]