mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2024-12-25 05:48:07 -05:00
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.
This commit is contained in:
parent
94d0efffb3
commit
8749f31485
2 changed files with 10 additions and 3 deletions
|
@ -179,9 +179,11 @@ (define (reverse/dot lst)
|
||||||
(match lst
|
(match lst
|
||||||
(() result)
|
(() result)
|
||||||
(((? dot?) . rest)
|
(((? dot?) . rest)
|
||||||
(let ((dotted (reverse rest)))
|
(if (pair? rest)
|
||||||
(set-cdr! (last-pair dotted) (car result))
|
(let ((dotted (reverse rest)))
|
||||||
dotted))
|
(set-cdr! (last-pair dotted) (car result))
|
||||||
|
dotted)
|
||||||
|
(car result)))
|
||||||
((x . rest) (loop (cons x result) rest)))))
|
((x . rest) (loop (cons x result) rest)))))
|
||||||
|
|
||||||
(let loop ((blank-line? blank-line?)
|
(let loop ((blank-line? blank-line?)
|
||||||
|
|
|
@ -58,6 +58,11 @@ (define-syntax-rule (test-pretty-print/sequence str args ...)
|
||||||
(call-with-input-string "(a . b)"
|
(call-with-input-string "(a . b)"
|
||||||
read-with-comments))
|
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"
|
(test-equal "read-with-comments: list with blank line"
|
||||||
`(list with ,(vertical-space 1) blank line)
|
`(list with ,(vertical-space 1) blank line)
|
||||||
(call-with-input-string "\
|
(call-with-input-string "\
|
||||||
|
|
Loading…
Reference in a new issue