diff options
-rw-r--r-- | guix/read-print.scm | 8 | ||||
-rw-r--r-- | tests/read-print.scm | 5 |
2 files changed, 10 insertions, 3 deletions
diff --git a/guix/read-print.scm b/guix/read-print.scm index d834105dce..83b9a61b35 100644 --- a/guix/read-print.scm +++ b/guix/read-print.scm @@ -179,9 +179,11 @@ BLANK-LINE? is true, assume PORT is at the beginning of a new line." (match lst (() result) (((? dot?) . rest) - (let ((dotted (reverse rest))) - (set-cdr! (last-pair dotted) (car result)) - dotted)) + (if (pair? rest) + (let ((dotted (reverse rest))) + (set-cdr! (last-pair dotted) (car result)) + dotted) + (car result))) ((x . rest) (loop (cons x result) rest))))) (let loop ((blank-line? blank-line?) diff --git a/tests/read-print.scm b/tests/read-print.scm index c2b236b172..9e1d8038f1 100644 --- a/tests/read-print.scm +++ b/tests/read-print.scm @@ -58,6 +58,11 @@ expressions." (call-with-input-string "(a . b)" read-with-comments)) +(test-equal "read-with-comments: half dot notation" + '(lambda x x) + (call-with-input-string "(lambda (. x) x)" + read-with-comments)) + (test-equal "read-with-comments: list with blank line" `(list with ,(vertical-space 1) blank line) (call-with-input-string "\ |