GNU bug report logs -
#54652
[PATCH 1/2] guix: Only check the object type once in the MATCH-RECORD expansion.
Previous Next
Reported by: Attila Lendvai <attila <at> lendvai.name>
Date: Thu, 31 Mar 2022 12:49:01 UTC
Severity: normal
Tags: patch
Done: Attila Lendvai <attila <at> lendvai.name>
Bug is archived. No further changes may be made.
Full log
Message #8 received at 54652 <at> debbugs.gnu.org (full text, mbox):
E.g. (match-record obj <type> (field1 (field2 var-name)) ...)
* guix/records.scm (match-record/fields): Implement it.
---
a real world example i was facing: a field name is the same
as an object constructor, and thus shadows it in a
match-record form, unless a different variable name is chosen.
guix/records.scm | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/guix/records.scm b/guix/records.scm
index e311086d73..492ab2aed6 100644
--- a/guix/records.scm
+++ b/guix/records.scm
@@ -537,12 +537,15 @@ (define (recutils->alist port)
(define-syntax match-record/fields
(syntax-rules ()
- ((_ record type (field fields ...) body ...)
- (let ((field ((record-accessor type 'field) record)))
+ ((_ record type ((field-name variable-name) fields ...) body ...)
+ (let ((variable-name ((record-accessor type 'field-name) record)))
;; TODO compute indices and report wrong-field-name errors at
;; expansion time
;; TODO support thunked and delayed fields
(match-record/fields record type (fields ...) body ...)))
+ ((_ record type (field fields ...) body ...)
+ ;; Channel it back into the canonical form above.
+ (match-record/fields record type ((field field) fields ...) body ...))
((_ record type () body ...)
(begin body ...))))
--
2.34.0
This bug report was last modified 2 years and 182 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.