From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms9.migadu.com with LMTPS id yADYDlbySmR7rgAASxT56A (envelope-from ) for ; Fri, 28 Apr 2023 00:08:22 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id cGqtDlbySmRX9wAAauVa8A (envelope-from ) for ; Fri, 28 Apr 2023 00:08:22 +0200 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 155D418BC2 for ; Fri, 28 Apr 2023 00:08:22 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ps9mY-0005Le-9i; Thu, 27 Apr 2023 18:08:06 -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 1ps9mV-0005Kd-IW for guix-patches@gnu.org; Thu, 27 Apr 2023 18:08:03 -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 1ps9mU-0007Hk-Ff for guix-patches@gnu.org; Thu, 27 Apr 2023 18:08:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ps9mU-0000ka-40 for guix-patches@gnu.org; Thu, 27 Apr 2023 18:08:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#63135] [PATCH 1/3] records: match-record: Raise a syntax error if TYPE is nonexistent. References: <20230427220452.4972-1-paren@disroot.org> In-Reply-To: <20230427220452.4972-1-paren@disroot.org> Resent-From: "(" Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 27 Apr 2023 22:08:02 +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.16826332232791 (code B ref 63135); Thu, 27 Apr 2023 22:08:02 +0000 Received: (at 63135) by debbugs.gnu.org; 27 Apr 2023 22:07:03 +0000 Received: from localhost ([127.0.0.1]:59971 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ps9lW-0000iq-Jc for submit@debbugs.gnu.org; Thu, 27 Apr 2023 18:07:03 -0400 Received: from knopi.disroot.org ([178.21.23.139]:53500) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ps9lV-0000iO-BG for 63135@debbugs.gnu.org; Thu, 27 Apr 2023 18:07:01 -0400 Received: from localhost (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id 2B1AC401FC; Fri, 28 Apr 2023 00:07:00 +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 QMpgJ3mA1ZBP; Fri, 28 Apr 2023 00:06:59 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1682633218; bh=GPhznM6wNK5AMuy0Nb33NHq6jGF40qkOAqXeIPrXDZY=; h=From:To:Cc:Subject:Date; b=fSGYPvir7OlnsiG/7szDpE8QUjGFzce5vuywAjVzRo0Z4NZoQDW9ijtimJ4fiSZRz v3AyPKOpaFcJu0k/YVUrhWtqGxMvzhm9HMxMtnFnvVpamsLFHvFf8gJZQKnqvqk470 Au/AhBBpw3d0iS1ekBu1Xd7nP/ZprNxmqtUa3UlUmsCBRgMMnOezBG0qw3NgofyyBm nm0MJ0Q9NFVgC2IL/Mb7USRfvd0VCIPB3nRRJkUzPeI1O51l2mPB4ZgkQIR5SaHYrL daKqsw0qHf6PO8kzHTVuahEXubwJT4kBxiUXyu7NaeyU9G+mQDy7KQhdwJEEBzTRPE tVvlN2L8j7rmg== Date: Thu, 27 Apr 2023 23:06:51 +0100 Message-Id: <20230427220653.5228-1-paren@disroot.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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" From: "\( via Guix-patches" via Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: guix-patches-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Seal: i=1; s=key1; d=yhetil.org; t=1682633302; a=rsa-sha256; cv=none; b=I8Cl1NkVkpuLUM1hpSWB+T7jz1eZNyMBiNyRYEz/2wXPAz3mTgIz3INU1Z3nSNxpQfnVjI yDh7YnMwCTP58UQH/F+dzbOd153OPFi3FiYHTFXtlqPJvZgetuYkxJfcIuea1fjAa3yerc oVlGpl7jrVrBtKRRIM4SXtgPKTCOF7AhwIcIXfDs47AvC6CmgpuKWpuSM7+d5jCl4kLvAK ACB/SY8ojmTuw0yfCP0a7twjtwrAnPFXfvZMSaG9d0FHvEdDNnuByMrBKer9/jQ0cDsEB4 o85XNt0fdqQP4T1d5loocLtYlpHGNSrYzXM1YiIaqiE5axKQbp3wXsxS58/xbQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=disroot.org header.s=mail header.b=fSGYPvir; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1682633302; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=PtiH602+qwKgToBeCP6JyTFeD/NbP60OWV6dtVbKIUA=; b=SyAXr4i4Cn/bHRhRQLzJmpABezutL57ddbUJZaq8w0vYkpzE6lZ9jGYCffO6+ASCFGo3tq pNFEZxONF6mOPZR81Fzc6pgPPw2LbaRT2BuJOXoPB/HrNBadpdbUleJ3AObsQOEK41UTFy 9+X4g/1AjKahNnxCEA1pRgfNU9xvemlUOxg8IZELCgma+JaiAjlanvtAzjGBRvQu3H08gM /F2bBxl6DDzd3kZwSopSqCzBIPpmrES9dAEhcIbtBClS2p7HLLZ+AwjYPQJt52+T8j7Yu/ ac1De2Qc27gLWtyV4HA47IQTW5bkK0xs37K0PhWiw7FD1p6VDVOF6QQMT08A8g== X-Migadu-Scanner: scn1.migadu.com Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=disroot.org header.s=mail header.b=fSGYPvir; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -1.70 X-Spam-Score: -1.70 X-Migadu-Queue-Id: 155D418BC2 X-TUID: gRmgG7sAb2sP * 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 ...) base-commit: d59b4764f3171b1430a6d3b954659b8aab730475 -- 2.39.2