diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2023-12-08 21:14:51 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2023-12-08 21:14:51 -0800 |
commit | 2b896e09bdf71fb94e40a105b681c26938daa961 (patch) | |
tree | d86ed08a261777b73ba120446bcd8d776f94415f | |
parent | 7c54bf4d7b251cbe49ee1eb56f167917c772671b (diff) | |
download | txr-2b896e09bdf71fb94e40a105b681c26938daa961.tar.gz txr-2b896e09bdf71fb94e40a105b681c26938daa961.tar.bz2 txr-2b896e09bdf71fb94e40a105b681c26938daa961.zip |
print: print/read consistency problem with rcons.
* lib.c (obj_print_impl): Do not print (rcons X Y)
as X..Y if X looks like (rcons ...). This
causes the problem that (rcons (rcons 1 2) 3)
prints as 1..2..3, a notation which unambiguously
means (rcons 1 (rcons 2 3)).
* tests/012/syntax.tl: New test cases.
-rw-r--r-- | lib.c | 3 | ||||
-rw-r--r-- | tests/012/syntax.tl | 9 |
2 files changed, 11 insertions, 1 deletions
@@ -14859,7 +14859,8 @@ val obj_print_impl(val obj, val out, val pretty, struct strm_ctx *ctx) goto list; } } else if (sym == rcons_s && have_args - && consp(cdr(args)) && !(cddr(args))) + && consp(cdr(args)) && !(cddr(args)) && + (!consp(arg) || car(arg) != rcons_s)) { obj_print_impl(arg, out, pretty, ctx); put_string(lit(".."), out); diff --git a/tests/012/syntax.tl b/tests/012/syntax.tl index d2fab599..bc7d9668 100644 --- a/tests/012/syntax.tl +++ b/tests/012/syntax.tl @@ -63,3 +63,12 @@ '(1.234,e+12) (1.234 (sys:unquote e+12)) '(1.,234) (1.0 (sys:unquote 234))) +(mtest + (read "0..1") (rcons 0 1) + (read "0..1..2") (rcons 0 (rcons 1 2))) + +(mtest + (tostring '(rcons 0 1)) "0..1" + (tostring '(rcons 0 (rcons 1 2))) "0..1..2" + (tostring '(rcons (rcons 0 1) 2)) "(rcons 0..1 2)" + (tostring '(rcons (rcons 0 1) (rcons 2 3))) "(rcons 0..1 2..3)") |