From 8749f31485888c587c6f88a0a7bdd48cc9e8c9b8 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Fri, 5 May 2023 18:22:56 +0200 Subject: 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 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'guix/read-print.scm') 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?) -- cgit v1.2.3