[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
06/26: records: match-record: Raise a syntax error if TYPE is nonexisten
From: |
guix-commits |
Subject: |
06/26: records: match-record: Raise a syntax error if TYPE is nonexistent. |
Date: |
Sun, 4 Jun 2023 05:38:32 -0400 (EDT) |
jpoiret pushed a commit to branch master
in repository guix.
commit 1a4aace3af85bdfd5f513a4c5bb6925d1d0f50be
Author: (unmatched-parenthesis <paren@disroot.org>
AuthorDate: Fri Apr 28 20:19:01 2023 +0100
records: match-record: Raise a syntax error if TYPE is nonexistent.
* 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>
Signed-off-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 @@ error-reporting purposes."
(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 @@ inherited."
"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 @@ found."
#'(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 ...)
- 07/26: records: match-record: Support thunked and delayed fields., (continued)
- 07/26: records: match-record: Support thunked and delayed fields., guix-commits, 2023/06/04
- 08/26: dir-locals: Fix MATCH-RECORD indentation., guix-commits, 2023/06/04
- 09/26: records: Add MATCH-RECORD-LAMBDA., guix-commits, 2023/06/04
- 20/26: build-system: New agda-build-system., guix-commits, 2023/06/04
- 11/26: tests: records: Add test for ellipsis in body., guix-commits, 2023/06/04
- 12/26: gnu: Add ghc-peano., guix-commits, 2023/06/04
- 26/26: channels: Raise an error if dependency's introduction is malformed, guix-commits, 2023/06/04
- 04/26: gnu: proot: Update to 5.4.0 and fix clone3 behavior., guix-commits, 2023/06/04
- 02/26: gnu: heimdal: Run autoreconf., guix-commits, 2023/06/04
- 03/26: gnu: heimdal: Drop obsolete and insecure user tools., guix-commits, 2023/06/04
- 06/26: records: match-record: Raise a syntax error if TYPE is nonexistent.,
guix-commits <=
- 10/26: records: match-record: Do not show internal form., guix-commits, 2023/06/04
- 14/26: gnu: agda: Update to 2.6.3 and switch to git-fetch., guix-commits, 2023/06/04
- 16/26: gnu: emacs-agda2-mode: No longer inherit from agda., guix-commits, 2023/06/04
- 17/26: gnu: emacs-agda2-mode: Switch to G-Exps., guix-commits, 2023/06/04
- 18/26: gnu: agda: Add AGDA_LIBDIRS search-path., guix-commits, 2023/06/04
- 19/26: build-system/haskell: Export default-haskell., guix-commits, 2023/06/04
- 24/26: gnu: Add agda-1lab., guix-commits, 2023/06/04
- 22/26: gnu: Add agda-categories., guix-commits, 2023/06/04
- 25/26: gnu: agda-ial: Update to ded30c410d5d40142249686572aa1acd1b2f8cc7., guix-commits, 2023/06/04
- 15/26: gnu: agda: Build info manual., guix-commits, 2023/06/04