bug#49623: [PATCH] Parse #{{}}# properly.

Maxime Devos <[email protected]>
Newsgroups gmane.lisp.guile.bugs
Message-ID <[email protected]>
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.
0001-ice-9-read-Parse-properly.patch (text/x-patch, 1.8 KB)
From 9fb7cff1a2544aae3827db1a781be6e5c367d8c0 Mon Sep 17 00:00:00 2001
From: Maxime Devos <[email protected]>
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
signature.asc (application/pgp-signature, 260 B)
-----BEGIN PGP SIGNATURE-----

iI0EABYKADUWIQTB8z7iDFKP233XAR9J4+4iGRcl7gUCYPRwBBccbWF4aW1lZGV2
b3NAdGVsZW5ldC5iZQAKCRBJ4+4iGRcl7gw+AP4xAZhnI/22hRTuhNdsxIqZ5DP5
uvkmsfHSwfIQTqKpoAEA6AoIAYj+TaBgqioygaOBDnY+stD4nIf81h68ry1QUw0=
=dDYU
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.