From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2.migadu.com ([2001:41d0:700:3204::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms8.migadu.com with LMTPS id sBGdFMmId2U2ZwAAkFu2QA (envelope-from ) for ; Mon, 11 Dec 2023 23:10:17 +0100 Received: from aspmx1.migadu.com ([2001:41d0:303:e16b::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2.migadu.com with LMTPS id UEGYDcmId2VydgEAe85BDQ (envelope-from ) for ; Mon, 11 Dec 2023 23:10:17 +0100 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=none; 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"; dmarc=pass (policy=none) header.from=gnu.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1702332616; 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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=K3GmbASTn+wm3BOyta9uj5bDU7xhBCIAUh0s+RmzYRE=; b=pDu9dpa9FdVT3Feb2BT7Jt5t0pgmkmCMdF8nTrlqY2IH5UFem7EfsdairfRKh29UUCOroc EbBLss/7uRvnLRqLBL5yNCQeKa8SYqTKWp4Q0DD+u52aczwOnAUTxrVs7uQN0hMoHhz9mH xwPaupGGRio823wRGi9DfZG6gp2Jv41mW37TTy15yJu1+Gvir3TMYsH/iTdcyNvg5mweNi Bh3/kcztdabO74tdg/FzBeno5GmEPe3ayfYzoLP2xylKMSkO+jILWdW73tIhTRyw2LxYJi JhgHg3m4eJUb2tSxTYUXwXL9NKpBiWoP35fgH0hQivjjOoDihJWlejM3hVBQIw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; 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"; dmarc=pass (policy=none) header.from=gnu.org ARC-Seal: i=1; s=key1; d=yhetil.org; t=1702332616; a=rsa-sha256; cv=none; b=sU/p6kwnSKcjoJK4N2ZPT/y026G3LKsvpvt4lAQ/kQ7ASi27aAqUssOUdQWtnZ8QHw3HOt EvJ/HGCLB1AELgCqpdqCOsWG5Y6U04rkEV6PCmSF6OlhhDDz+1P8kRYZK1xS4Yhuj6rBkn 4W8CPDk+Kjc3kqlLn6rxzXZsnbywL1/REgr/InJUW7Xs8cgXilF46luXTyPyCGIYRT93Hy 8b+PJw7iOjg0vrdG16Xzuvolikdc49iLzXP/u1KqQVGCfbf7logWiH90KAFraKPJxZyJVc YwEIFhjloD7aUavNAzGk+czCk7IsGN1oRFddBYi9+RvmgVsQFaESpVrBjPe73A== 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 2489A523D4 for ; Mon, 11 Dec 2023 23:10:15 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rCoTN-0005u6-4l; Mon, 11 Dec 2023 17:09:57 -0500 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 1rCoTK-0005rg-P7 for guix-patches@gnu.org; Mon, 11 Dec 2023 17:09:54 -0500 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rCoTH-00068y-DQ; Mon, 11 Dec 2023 17:09:53 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rCoTS-0004LP-AH; Mon, 11 Dec 2023 17:10:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#67788] [PATCH] records: Check for missing mandatory innate fields when inheriting. Resent-From: Skyler Ferris Original-Sender: "Debbugs-submit" Resent-CC: guix@cbaines.net, dev@jpoiret.xyz, ludo@gnu.org, othacehe@gnu.org, rekado@elephly.net, zimon.toutoune@gmail.com, me@tobias.gr, guix-patches@gnu.org Resent-Date: Mon, 11 Dec 2023 22:10:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 67788 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 67788@debbugs.gnu.org Cc: Skyler Ferris , Christopher Baines , Josselin Poiret , Ludovic =?UTF-8?Q?Court=C3=A8s?= , Mathieu Othacehe , Ricardo Wurmus , Simon Tournier , Tobias Geerinckx-Rice X-Debbugs-Original-To: guix-patches@gnu.org X-Debbugs-Original-Xcc: Christopher Baines , Josselin Poiret , Ludovic =?UTF-8?Q?Court=C3=A8s?= , Mathieu Othacehe , Ricardo Wurmus , Simon Tournier , Tobias Geerinckx-Rice Received: via spool by submit@debbugs.gnu.org id=B.170233259516680 (code B ref -1); Mon, 11 Dec 2023 22:10:02 +0000 Received: (at submit) by debbugs.gnu.org; 11 Dec 2023 22:09:55 +0000 Received: from localhost ([127.0.0.1]:54847 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rCoTL-0004Ky-An for submit@debbugs.gnu.org; Mon, 11 Dec 2023 17:09:55 -0500 Received: from lists.gnu.org ([2001:470:142::17]:49848) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rCoTJ-0004Kl-8W for submit@debbugs.gnu.org; Mon, 11 Dec 2023 17:09:53 -0500 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 1rCoSw-0005nB-Ri for guix-patches@gnu.org; Mon, 11 Dec 2023 17:09:31 -0500 Received: from c-24-143-119-132.customer.broadstripe.net ([24.143.119.132] helo=localhost) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rCoSs-00066R-J9 for guix-patches@gnu.org; Mon, 11 Dec 2023 17:09:30 -0500 Received: from [127.0.0.1] (helo=localhost.localdomain) by localhost with esmtp (Exim 4.96.1) (envelope-from ) id 1rCoSp-0006Vx-1N; Mon, 11 Dec 2023 14:09:22 -0800 Date: Mon, 11 Dec 2023 14:09:19 -0800 Message-ID: <5a0f596c5bbcc75e3ca50d37066f42baca354236.1702330063.git.skyvine@protonmail.com> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: softfail client-ip=24.143.119.132; envelope-from=skyvine@protonmail.com; helo=localhost X-Spam_score_int: 72 X-Spam_score: 7.2 X-Spam_bar: +++++++ X-Spam_report: (7.2 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FROM=0.001, FSL_HELO_NON_FQDN_1=0.001, HELO_LOCALHOST=3.828, KHOP_HELO_FCRDNS=0.26, RCVD_IN_PBL=3.335, RDNS_DYNAMIC=0.982, SPF_SOFTFAIL=0.665, SPOOFED_FREEMAIL=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: reject 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: Skyler Ferris X-ACL-Warn: , Skyler Ferris via Guix-patches From: Skyler Ferris 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-Country: US X-Migadu-Flow: FLOW_IN X-Migadu-Scanner: mx13.migadu.com X-Migadu-Spam-Score: 0.09 X-Spam-Score: 0.09 X-Migadu-Queue-Id: 2489A523D4 X-TUID: elnNJIgr+P+i This gives the user a more helpful error message if they inherit from another instance but forget to supply a value for a field which is innate and has no default. * guix/records.scm (record-inheritance): Check for missing innate fields Change-Id: I08b898d8da551af50aa5b0b60187dcad8d259bc1 --- This fixes issue #67785 by providing the same error message that is provided when the value is not inherited. After applying this patch `make check` had one failure, which seems to be unrelated. It was the test "pypi->guix-package, no wheel"; for some reason, the download of the wheel file failed. All other tests, in particular the tests in `tests/records.scm`, passed. I additionally manually inspected the values computed in the `let*` against a type that contained 4 fields, for each combination of mandatory/non-mandatory and optional/non-optional, and they contained the expected values. guix/records.scm | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/guix/records.scm b/guix/records.scm index f4d12a861d..109c5cf4dc 100644 --- a/guix/records.scm +++ b/guix/records.scm @@ -161,6 +161,15 @@ (define-syntax make-syntactic-constructor (record-error 'name s "extraneous field initializers ~a" unexpected))) + ;; Make sure all mandatory and innate fields are included. + (let* ((fields (map (compose car syntax->datum) field+value)) + (optional (map (compose car syntax->datum) 'defaults)) + (mandatory (lset-difference eq? '(expected ...) optional)) + (mandatory+innate (lset-intersection eq? mandatory 'innate)) + (missing (lset-difference eq? mandatory+innate fields))) + (when (pair? missing) + (record-error 'name s "missing field initializers ~a" missing))) + #`(make-struct/no-tail type #,@(map (lambda (field index) (or (field-inherited-value field) base-commit: 2b782f67266b42bb40015bd23ce2443be2f9b01f -- 2.41.0