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

Maxime Devos <[email protected]>
Newsgroups gmane.lisp.guile.bugs
Message-ID <71e366c5e151d73c9b9a33345833f379d4c6d4f5.camel__47430.543512904$1626778577$gmane$org@telenet.be>
Maxime Devos schreef op zo 18-07-2021 om 21:47 [+0200]:
> It turns out that the test fails when the patch
> is applies to [email protected].  I'll rebase and try
> to figure things out.

With the revised patch, tests succeed and the Guile
library now compiles successfully.

Greetings,
Maxime.
0001-ice-9-read-Parse-properly.patch (text/x-patch, 2.1 KB)
From 40b0b29c05d521cd8901988fa2bc71547f917f48 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 but CH isn't
  #\#, don't eat CH.
* test-suite/tests/reader.test
  ("#{}#): Add four test cases.
---
 module/ice-9/read.scm        | 7 +++++--
 test-suite/tests/reader.test | 5 +++++
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/module/ice-9/read.scm b/module/ice-9/read.scm
index ac407739f..283933064 100644
--- a/module/ice-9/read.scm
+++ b/module/ice-9/read.scm
@@ -556,12 +556,15 @@
     (string->symbol
      (list->string
       (let lp ((saw-brace? #f))
-        (let ((ch (next-not-eof)))
+        (let lp/inner ((ch (next-not-eof))
+                       (saw-brace? saw-brace?))
           (cond
            (saw-brace?
             (if (eqv? ch #\#)
                 '()
-                (cons #\} (lp #f))))
+                ;; Don't eat CH, see
+                ;; <https://debbugs.gnu.org/cgi/bugreport.cgi?bug=49623>.
+                (cons #\} (lp/inner ch #f))))
            ((eqv? ch #\})
             (lp #t))
            ((eqv? ch #\\)
diff --git a/test-suite/tests/reader.test b/test-suite/tests/reader.test
index 1481a0a5d..ad7c6d575 100644
--- a/test-suite/tests/reader.test
+++ b/test-suite/tests/reader.test
@@ -536,6 +536,11 @@
 
 (with-test-prefix "#{}#"
   (pass-if (equal? (read-string "#{}#") '#{}#))
+  ;; See <https://debbugs.gnu.org/cgi/bugreport.cgi?bug=49623>
+  (pass-if (equal? (read-string "#{}}#") (string->symbol "}")))
+  (pass-if (equal? (read-string "#{}}}#") (string->symbol "}}")))
+  (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+4iGRcl7gUCYPardhccbWF4aW1lZGV2
b3NAdGVsZW5ldC5iZQAKCRBJ4+4iGRcl7u5LAQDqoLNCXgIVRbCCJhgDyXb0/ja8
W9f0pCyUoKE46h5DXAD/SimF0lbkFHWAaWskCe71Gd5CT56O4IUnpEc3+fuXOQ0=
=R5xl
-----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.