From patchwork Mon Dec 11 22:09:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Skyler Ferris X-Patchwork-Id: 57532 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 E5E5627BBE2; Mon, 11 Dec 2023 22:10:16 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, MAILING_LIST_MULTI,SPF_HELO_PASS 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 EF5F327BBE9 for ; Mon, 11 Dec 2023 22:10:15 +0000 (GMT) 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 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 X-Patchwork-Original-From: Skyler Ferris via Guix-patches via From: Skyler Ferris 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 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(+) base-commit: 2b782f67266b42bb40015bd23ce2443be2f9b01f 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)