From patchwork Fri Apr 28 19:19:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "\\(" X-Patchwork-Id: 49658 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id B748327BBE2; Fri, 28 Apr 2023 20:20:38 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-3.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id AB0B627BBEB for ; Fri, 28 Apr 2023 20:20:37 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1psTdg-0002SZ-Up; Fri, 28 Apr 2023 15:20:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1psTdV-0002Pd-Qh for guix-patches@gnu.org; Fri, 28 Apr 2023 15:20:05 -0400 Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1psTdU-0004O8-Db for guix-patches@gnu.org; Fri, 28 Apr 2023 15:20:05 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1psTdU-00063l-8w for guix-patches@gnu.org; Fri, 28 Apr 2023 15:20:04 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#63135] [PATCH v2 1/5] records: match-record: Raise a syntax error if TYPE is nonexistent. Resent-From: "(" Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 28 Apr 2023 19:20:04 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 63135 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 63135@debbugs.gnu.org Cc: "\(" , Josselin Poiret Received: via spool by 63135-submit@debbugs.gnu.org id=B63135.168270956223151 (code B ref 63135); Fri, 28 Apr 2023 19:20:04 +0000 Received: (at 63135) by debbugs.gnu.org; 28 Apr 2023 19:19:22 +0000 Received: from localhost ([127.0.0.1]:34542 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1psTcn-00061G-Qr for submit@debbugs.gnu.org; Fri, 28 Apr 2023 15:19:22 -0400 Received: from knopi.disroot.org ([178.21.23.139]:41914) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1psTcl-00060U-Gy for 63135@debbugs.gnu.org; Fri, 28 Apr 2023 15:19:19 -0400 Received: from localhost (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id 0323B40274; Fri, 28 Apr 2023 21:19:19 +0200 (CEST) X-Virus-Scanned: SPAM Filter at disroot.org Received: from knopi.disroot.org ([127.0.0.1]) by localhost (disroot.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id QQTJKUjPd4rO; Fri, 28 Apr 2023 21:19:15 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1682709555; bh=8BmRwHNyibV4LMLlHFnVJrXMVrH1J/ivFDj7yyHIQKM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=BuBC4y/xa8T62CYq7v2HhLy/Ep/NT0Xfu0vYmzjKPAccADO36SquZPU/eXv44rbG7 NWdLiaWn1FrPF/0fu1FKm2vJwvwKsQs8oIpW9hholNS9rEjBTxWyJDzC9Y7ycOm63Y G29jMVYhRqzdaWX+U+kTvq5JAYwStYrqopjt0+VbqX+C4FrcvAfjdUgV2vKl1WiZVj J64tp23IXvkLL1V+0W312yUZ86cf0FoB2y0VNMz7xno10L625LkgZ4PD/uUx+Mjluf 8aMmsXpdlswMbvgJiHJdUJofI/Du/71YSmeAVtNT18cptcxY8YUaKoCa9Gz1jYZY2n UzcjD0JxvIzpw== Date: Fri, 28 Apr 2023 20:19:01 +0100 Message-Id: <20230428191905.13860-2-paren@disroot.org> In-Reply-To: <20230428191905.13860-1-paren@disroot.org> References: <20230428191905.13860-1-paren@disroot.org> MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: "\(" X-ACL-Warn: , "\( via Guix-patches" X-Patchwork-Original-From: "\( via Guix-patches" via From: "\\(" Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * guix/records.scm (match-record): Raise a human-compherensible syntax error if the given record type identifier is unbound. Co-authored-by: Josselin Poiret --- 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 ...)