all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "\( via Guix-patches" via <guix-patches@gnu.org>
To: 63135@debbugs.gnu.org
Cc: "\(" <paren@disroot.org>, Josselin Poiret <dev@jpoiret.xyz>
Subject: [bug#63135] [PATCH 1/3] records: match-record: Raise a syntax error if TYPE is nonexistent.
Date: Thu, 27 Apr 2023 23:06:51 +0100	[thread overview]
Message-ID: <20230427220653.5228-1-paren@disroot.org> (raw)
In-Reply-To: <20230427220452.4972-1-paren@disroot.org>

* guix/records.scm (match-record): Raise a human-compherensible syntax error
  if the given record type identifier is unbound.

Co-authored-by: Josselin Poiret <dev@jpoiret.xyz>
---
 guix/records.scm | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/guix/records.scm b/guix/records.scm
index 7d43b064d8..d8966998c1 100644
--- a/guix/records.scm
+++ b/guix/records.scm
@@ -105,7 +105,12 @@ (define (report-duplicate-field-specifier name ctor)
 
 (define-syntax map-fields
   (lambda (x)
-    (syntax-violation 'map-fields "bad use of syntactic keyword" x x)))
+    (syntax-case x ()
+      ((_ type within)
+       (syntax-violation (syntax->datum #'within)
+                         "undefined guix record-type"
+                         #'type))
+      (_ (syntax-violation 'map-fields "bad use of syntactic keyword" x x)))))
 
 (define-syntax-parameter this-record
   (lambda (s)
@@ -459,7 +464,7 @@ (define-syntax type
                    "This macro lets us query record type info at
 macro-expansion time."
                    (syntax-case s (map-fields)
-                     ((_ map-fields macro)
+                     ((_ (map-fields _ _) macro)
                       #'(macro (field ...)))
                      (id
                       (identifier? #'id)
@@ -595,7 +600,7 @@ (define-syntax match-record-inner
        #'(let-syntax ((field-offset (syntax-rules ()
 			              ((_ f)
                                        (lookup-field field 0 f)))))
-           (let* ((offset (type map-fields field-offset))
+           (let* ((offset (type (map-fields type match-record) field-offset))
                   (variable (struct-ref record offset)))
              (match-record-inner record type (rest ...) body ...))))
       ((_ record type (field rest ...) body ...)

base-commit: d59b4764f3171b1430a6d3b954659b8aab730475
-- 
2.39.2





  reply	other threads:[~2023-04-27 22:08 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-27 22:04 [bug#63135] [PATCH 0/3] MATCH-RECROD improvements ( via Guix-patches via
2023-04-27 22:06 ` ( via Guix-patches via [this message]
2023-04-27 22:06   ` [bug#63135] [PATCH 2/3] records: match-record: Display more helpful field-not-found error ( via Guix-patches via
2023-04-27 22:06   ` [bug#63135] [PATCH 3/3] records: match-record: Support thunked and delayed fields ( via Guix-patches via
2023-04-28 19:19 ` [bug#63135] [PATCH v2 0/5] MATCH-RECORD improvements ( via Guix-patches via
2023-04-28 19:19   ` [bug#63135] [PATCH v2 1/5] records: match-record: Raise a syntax error if TYPE is nonexistent ( via Guix-patches via
2023-05-19 15:22     ` [bug#63135] [PATCH 0/3] MATCH-RECROD improvements Ludovic Courtès
2023-04-28 19:19   ` [bug#63135] [PATCH v2 2/5] records: match-record: Display more helpful field-not-found error ( via Guix-patches via
2023-05-19 15:25     ` [bug#63135] [PATCH 0/3] MATCH-RECROD improvements Ludovic Courtès
2023-04-28 19:19   ` [bug#63135] [PATCH v2 3/5] records: match-record: Support thunked and delayed fields ( via Guix-patches via
2023-05-19 15:25     ` [bug#63135] [PATCH 0/3] MATCH-RECROD improvements Ludovic Courtès
2023-04-28 19:19   ` [bug#63135] [PATCH v2 4/5] dir-locals: Fix MATCH-RECORD indentation ( via Guix-patches via
2023-05-19 15:27     ` [bug#63135] [PATCH 0/3] MATCH-RECROD improvements Ludovic Courtès
2023-05-20 18:02       ` ( via Guix-patches via
2023-05-24 14:11         ` Ludovic Courtès
2023-05-24 15:49           ` ( via Guix-patches via
2023-05-26 16:41             ` Ludovic Courtès
2023-05-27  0:55               ` ( via Guix-patches via
2023-04-28 19:19   ` [bug#63135] [PATCH v2 5/5] records: Add MATCH-RECORD-LAMBDA ( via Guix-patches via
2023-05-19 15:28     ` [bug#63135] [PATCH 0/3] MATCH-RECROD improvements Ludovic Courtès
2023-06-04  9:47   ` bug#63135: [PATCH v2 0/5] MATCH-RECORD improvements Josselin Poiret via Guix-patches via
2023-06-04 10:48     ` [bug#63135] " Josselin Poiret via Guix-patches via
2023-06-04 19:11     ` ( via Guix-patches via

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230427220653.5228-1-paren@disroot.org \
    --to=guix-patches@gnu.org \
    --cc=63135@debbugs.gnu.org \
    --cc=dev@jpoiret.xyz \
    --cc=paren@disroot.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.