[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
01/08: read-print: Correctly read "(. x)".
From: |
guix-commits |
Subject: |
01/08: read-print: Correctly read "(. x)". |
Date: |
Fri, 5 May 2023 18:06:09 -0400 (EDT) |
civodul pushed a commit to branch master
in repository guix.
commit 8749f31485888c587c6f88a0a7bdd48cc9e8c9b8
Author: Ludovic Courtès <ludo@gnu.org>
AuthorDate: Fri May 5 18:22:56 2023 +0200
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.
---
guix/read-print.scm | 8 +++++---
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 "\
- branch master updated (94d0efffb3 -> 64086a4fa4), guix-commits, 2023/05/05
- 02/08: read-print: Recognize 'wrap-program' and 'wrap-script' as special forms., guix-commits, 2023/05/05
- 01/08: read-print: Correctly read "(. x)".,
guix-commits <=
- 03/08: gnu: guile2.0-shepherd: Remove., guix-commits, 2023/05/05
- 04/08: gnu: bear: Build against 'abseil-cpp-cxxstd11'., guix-commits, 2023/05/05
- 05/08: gnu: lttng-tools: Fix build failure., guix-commits, 2023/05/05
- 06/08: gnu: git-crypt: Fix build issues on OpenSSL 3., guix-commits, 2023/05/05
- 07/08: gnu: mupdf: Update to 1.22.0., guix-commits, 2023/05/05
- 08/08: gnu: mupdf: Simplify snippet., guix-commits, 2023/05/05