GNU bug report logs - #60225
[PATCH] records: match-record supports specifying a different variable name.

Previous Next

Package: guix-patches;

Reported by: Attila Lendvai <attila <at> lendvai.name>

Date: Tue, 20 Dec 2022 17:42:02 UTC

Severity: normal

Tags: patch

Done: Ludovic Courtès <ludo <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Attila Lendvai <attila <at> lendvai.name>
To: 60225 <at> debbugs.gnu.org
Cc: Attila Lendvai <attila <at> lendvai.name>
Subject: [bug#60225] [PATCH v2 2/2] tests: records: Add a failing test for match-record.
Date: Wed, 21 Dec 2022 23:14:57 -0300
* tests/records.scm ("match-record, syntactic interference"): New failing test.
---

i'm not sure what's going on here, but it looks like a bug to me.

i've experienced this in real code, and the error message was
not very helpful.

 tests/records.scm | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/tests/records.scm b/tests/records.scm
index b1203dfeb7..8a48e2fd07 100644
--- a/tests/records.scm
+++ b/tests/records.scm
@@ -561,4 +561,27 @@ (define-record-type* <foo> foo make-foo
             (make-fresh-user-module)))
     (lambda (key . args) key)))
 
+(test-expect-fail 1)
+(test-equal "match-record, syntactic interference"
+  '(1 2)
+  (begin
+    (define* (make-form #:optional (bindings '()))
+      `(begin
+         (use-modules (guix records))
+
+         (let ((first 42))              ; here it does not interfere
+           (define-record-type* <foo> foo make-foo
+             foo?
+             (first  foo-first (default 1))
+             (second foo-second))
+
+           (let (,@bindings)            ; but here it does interfere
+             (match-record (foo (second 2)) <foo>
+               (first second)
+               (list first second))))))
+    ;; This works fine.
+    (eval (make-form) (make-fresh-user-module))
+    ;; But this fails, although I think it shouldn't.
+    (eval (make-form '((second 43))) (make-fresh-user-module))))
+
 (test-end)
-- 
2.35.1





This bug report was last modified 2 years and 147 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.