Hi guilers,

This fixes bug #49623.  I also added two additional test cases.
I'm rebuilding Guile right now and will re-run the entire test suite,
and I'll build the affected guile library with the fixed guile.

Greetings,
Maxime.
From 9fb7cff1a2544aae3827db1a781be6e5c367d8c0 Mon Sep 17 00:00:00 2001
From: Maxime Devos <maximede...@telenet.be>
Date: Sun, 18 Jul 2021 19:59:32 +0200
Subject: [PATCH] ice-9/read: Parse #{}}# properly.

This is a regression since Guile 3.0.2 and breaks compilation
of a Guile library.

* module/ice-9/read.scm
  (%read)[read-parenthesized]: When 'saw-brace?' is #t, do not
  reset 'saw-brace?' to #f if the current character is #\}.
* test-suite/tests/reader.test
  ("#{}#): Add two test cases.
---
 module/ice-9/read.scm        | 5 ++++-
 test-suite/tests/reader.test | 3 +++
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/module/ice-9/read.scm b/module/ice-9/read.scm
index 72811fdb8..3fcc6ae50 100644
--- a/module/ice-9/read.scm
+++ b/module/ice-9/read.scm
@@ -570,7 +570,10 @@
            (saw-brace?
             (if (eqv? ch #\#)
                 '()
-                (cons #\} (lp #f))))
+                ;; (eqv? ch #\}) is required instead of #f to allow for
+                ;; the trailing # to be preceded by two }, e.g.
+                ;; #{}}# or #{{a}}#.  See <https://bug.gnu.org/XXX>.
+                (cons #\} (lp (eqv? ch #\})))))
            ((eqv? ch #\})
             (lp #t))
            ((eqv? ch #\\)
diff --git a/test-suite/tests/reader.test b/test-suite/tests/reader.test
index ef11a4abd..134cb5ec3 100644
--- a/test-suite/tests/reader.test
+++ b/test-suite/tests/reader.test
@@ -508,6 +508,9 @@
 
 (with-test-prefix "#{}#"
   (pass-if (equal? (read-string "#{}#") '#{}#))
+  ;; ??? bugs.gnu.org
+  (pass-if (equal? (read-string "#{{}}#") (string->symbol "{}")))
+  (pass-if (equal? (read-string "#{{}b}#") (string->symbol "{}b")))
   (pass-if (not (equal? (read-string "(a #{.}# b)") '(a . b))))
   (pass-if (equal? (read-string "#{a}#") 'a))
   (pass-if (equal? (read-string "#{a b}#") '#{a b}#))
-- 
2.32.0

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to