From a6a74910fc4d02ffae4b9dcd76a8cd813e3170bf Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Thu, 23 Mar 2023 00:55:46 -0700 Subject: printer: [] shouldn't print as [. nil]. * lib.c (obj_print_impl): In the case when dwim has no args, and the logic short circuits to a closing brace, bypassing the loop, we should only use the dot notation if the terminating atom is other than nil. * tests/012/readprint.tl: Tests added. --- lib.c | 6 ++++-- tests/012/readprint.tl | 8 +++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/lib.c b/lib.c index f9b6ee30..d17e416f 100644 --- a/lib.c +++ b/lib.c @@ -14349,8 +14349,10 @@ val obj_print_impl(val obj, val out, val pretty, struct strm_ctx *ctx) if (sym == dwim_s) { put_char(chr('['), out); if (!have_args) { - put_string(lit(". "), out); - obj_print_impl(args, out, pretty, ctx); + if (args) { + put_string(lit(". "), out); + obj_print_impl(args, out, pretty, ctx); + } put_char(chr(']'), out); break; } diff --git a/tests/012/readprint.tl b/tests/012/readprint.tl index cf70320a..4298a85b 100644 --- a/tests/012/readprint.tl +++ b/tests/012/readprint.tl @@ -4,4 +4,10 @@ '[ . a] "[. a]" '[. a] "[. a]" '[ . @a] "[. @a]" - '[. @a] "[. @a]") + '[. @a] "[. @a]" + '[] "[]" + '[. 3] "[. 3]" + '[3 . 4] "[3 . 4]" + '(dwim) "[]" + '(dwim . 3) "[. 3]" + '(dwim 3 . 4) "[3 . 4]") -- cgit v1.2.3