me
/
guix
Archived
1
0
Fork 0

read-print: Correctly read "(. x)".

* guix/read-print.scm (read-with-comments): Check whether REST is a pair
before calling 'set-cdr!'.
* tests/read-print.scm ("read-with-comments: half dot notation"): New test.
master
Ludovic Courtès 2023-05-05 18:22:56 +02:00
parent 94d0efffb3
commit 8749f31485
No known key found for this signature in database
GPG Key ID: 090B11993D9AEBB5
2 changed files with 10 additions and 3 deletions

View File

@ -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?)

View File

@ -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 "\