From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id 2KBOM1uEVWFaVgEAgWs5BA (envelope-from ) for ; Thu, 30 Sep 2021 11:33:15 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id j5bYLluEVWFMGAAAbx9fmQ (envelope-from ) for ; Thu, 30 Sep 2021 09:33:15 +0000 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 4EF5D5C6F for ; Thu, 30 Sep 2021 11:33:15 +0200 (CEST) Received: from localhost ([::1]:40614 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mVsRF-0007CE-GO for larch@yhetil.org; Thu, 30 Sep 2021 05:33:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34492) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mVsR4-0007Be-EF for guix-patches@gnu.org; Thu, 30 Sep 2021 05:33:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:39936) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mVsR4-0000jD-6A for guix-patches@gnu.org; Thu, 30 Sep 2021 05:33:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mVsR3-0007tx-Nr for guix-patches@gnu.org; Thu, 30 Sep 2021 05:33:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#50914] [PATCH] records: Raise a &fix-hint if a field has multiple values. Resent-From: Maxime Devos Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 30 Sep 2021 09:33:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 50914 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 50914@debbugs.gnu.org Cc: Maxime Devos X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.163299436130346 (code B ref -1); Thu, 30 Sep 2021 09:33:01 +0000 Received: (at submit) by debbugs.gnu.org; 30 Sep 2021 09:32:41 +0000 Received: from localhost ([127.0.0.1]:51482 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mVsQj-0007tN-9J for submit@debbugs.gnu.org; Thu, 30 Sep 2021 05:32:41 -0400 Received: from lists.gnu.org ([209.51.188.17]:44000) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mVsQi-0007tG-4D for submit@debbugs.gnu.org; Thu, 30 Sep 2021 05:32:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34458) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mVsQh-00077m-EW for guix-patches@gnu.org; Thu, 30 Sep 2021 05:32:39 -0400 Received: from albert.telenet-ops.be ([2a02:1800:110:4::f00:1a]:47406) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mVsQf-0000Mu-6N for guix-patches@gnu.org; Thu, 30 Sep 2021 05:32:39 -0400 Received: from localhost.localdomain ([IPv6:2a02:1811:8c09:9d00:aaf1:9810:a0b8:a55d]) by albert.telenet-ops.be with bizsmtp id 09YZ260010mfAB4069YZ4W; Thu, 30 Sep 2021 11:32:33 +0200 From: Maxime Devos Date: Thu, 30 Sep 2021 11:32:29 +0200 Message-Id: <20210930093229.4730-1-maximedevos@telenet.be> X-Mailer: git-send-email 2.33.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telenet.be; s=r21; t=1632994353; bh=L5TSpsJm/x3kWZLhDpTtWitInyv05fL6lruxYTWVybc=; h=From:To:Cc:Subject:Date; b=Gzig5GuBcx6XwhLkV5xPof+web1YtnGzoyyXUK4i+iQ0k2vVEo8GoFzNEOBmwTeu1 d3WFBw3f48I1FfajVs7L8H3uJkJP+C+uwVo+T2Zze/OYm+BlFs+XXKbJACIBY9XM1+ gRh80iPdMX8XZpGfGghgmrWlL21xGw9c1Ste1QScC139TDhQnIG6fd0r2JzFf+Sw1Y LJk4HnM+S/UXJmqu8ujzs8mg82sq41CA8MpDqA95d/3dappoEZTPKxE10pgIol6j5e usAC4HCyEjNeK38IJCQTh4Gy1+DY33brf9+IPlUf9Apx9+v6OeR5sb99uwHCp6I4rd a9dSs8yaT1+uw== Received-SPF: pass client-ip=2a02:1800:110:4::f00:1a; envelope-from=maximedevos@telenet.be; helo=albert.telenet-ops.be X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1632994395; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: 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:dkim-signature; bh=L5TSpsJm/x3kWZLhDpTtWitInyv05fL6lruxYTWVybc=; b=KjneBDCLTfZjeKdt1zOp9cEllXWTwAfiJWNQy9qu9Djs8oJQbg/4h73DXYc3IimiDowxSP lBh8DEQcJnzqHJD1GFY5sKFq49RInL1FaPJyPOXa8QlExRV6WucJYibg7HPxHKMM8ddr2I iuRUM+VlspuCFt/UMwdc22tL7zqJVtliJBx87GhGNqSkg+8TfKjAsB+a4BqnHs1Z9YrmGC wpaPk41H9q/jdIVSt58+oN6ol/kTmOxmXWq3P6xnFrh0SX4A9pI5G1aHkxlwoN20GufKl7 b/yMBXVuiYcGAwxTeoWrDPl/R6xGWTNeMNAHRGC9q3iPvgSoJ6wnuAykGctLVQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1632994395; a=rsa-sha256; cv=none; b=bCbw62ip5778WSvnwU4mPyTKB9cfjoVpDzTUUAVPJ+AnOn/slo16uOogGuY1BzfodJa/ik 8jmkQqtDjfzpyAVmG5xMqtxTvwrigyY8hyAxnq2xvHxvBPXnk1fLndvxkMZvtduSPYCLJC aKFMRqxb0ZLvs8NS02SOwbA8rEHssLRkOZv+GGZKlo+TqpaPMA1/aM4aTzl1k9eh84AMRW HM4nkpcPxXAhrqqB6v0Xa5wOK4GXBlvYEmZdCaBrmufMH98ZDf3HIuVDMN/btChWQWoSEw OeZLhGYP6uRRRVMEjEpmECbcm0esUFodyZz8XNKMRIu5xsNPWUDGGLAp98A2GA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=telenet.be header.s=r21 header.b=Gzig5GuB; spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Spam-Score: -1.00 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=telenet.be header.s=r21 header.b=Gzig5GuB; dmarc=fail reason="SPF not aligned (relaxed)" header.from=telenet.be (policy=none); spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Queue-Id: 4EF5D5C6F X-Spam-Score: -1.00 X-Migadu-Scanner: scn1.migadu.com X-TUID: i9yp5SloJRcE * guix/records.scm (report-invalid-field-specifier): If 'weird' is something like (field (record ...) extra ...), hint that 'extra ...' should probably be moved inside (record ...). --- guix/records.scm | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/guix/records.scm b/guix/records.scm index ed94c83dac..db0c0a7ca0 100644 --- a/guix/records.scm +++ b/guix/records.scm @@ -1,6 +1,7 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021 Ludovic Courtès ;;; Copyright © 2018 Mark H Weaver +;;; Copyright © 2021 Maxime Devos ;;; ;;; This file is part of GNU Guix. ;;; @@ -21,10 +22,13 @@ #:use-module (srfi srfi-1) #:use-module (srfi srfi-9) #:use-module (srfi srfi-26) + #:use-module (srfi srfi-35) + #:use-module (ice-9 exceptions) #:use-module (ice-9 match) #:use-module (ice-9 regex) #:use-module (ice-9 rdelim) #:autoload (system base target) (target-most-positive-fixnum) + #:autoload (guix diagnostics) (&fix-hint) #:export (define-record-type* this-record @@ -83,10 +87,35 @@ error-reporting purposes." ;; WEIRD may be an identifier, thus lacking source location info, and ;; BINDINGS is a list, also lacking source location info. Hopefully ;; PARENT-FORM provides source location info. - (apply syntax-violation name "invalid field specifier" + (let ((forms (if parent-form (list parent-form #'weird) - (list #'weird))))))) + (list #'weird)))) + (syntax-case #'weird () + ;; common mistake + ((field (record-name fields ...) extra-value extra-value* ...) + (raise-exception + (condition + (&origin (origin name)) + (&message (message + (format #f "field ‘~a’ should only have one \ +value, but an extra value ‘~a’ was passed as well. Perhaps this extra \ +value was supposed to be a field specifier, and needs to be moved inside \ +the record ‘~a’?" + (syntax->datum #'field) + (syntax->datum #'extra-value) + (syntax->datum #'(record-name fields ...))))) + (&syntax (form (car forms)) + (subform (and (not (null? (cdr forms))) + (cadr forms)))) + (&fix-hint (hint (object->string + (syntax->datum + #'(field + (record-name fields ... extra-value + extra-value* ...))))))))) + (_ + (apply syntax-violation name + "invalid field specifier" forms)))))))) (define (report-duplicate-field-specifier name ctor) "Report the first duplicate identifier among the bindings in CTOR." base-commit: 808f9ffbd3106da4c92d2367b118b98196c9e81e prerequisite-patch-id: 7fdac44e8681baaf419cbf8da78cdebb8b9f9757 prerequisite-patch-id: 1f7f1597b9c85b2b1f9db1044d193bcf6ec8650e prerequisite-patch-id: 588ca94b9c4603424094a9cc2854c4f9bc83c7e4 prerequisite-patch-id: 82b4951463e8979d1c4cd15e1ca6a36308b21b51 prerequisite-patch-id: 75cdb9eb6b038adfb605253163b94efd51e0276c prerequisite-patch-id: 35140f4f2873d0b9f4fc8caca6ec2e013ecb830a prerequisite-patch-id: ed97d14afd166e7b6cac37e3aa87a85246f7e320 prerequisite-patch-id: 3f3d43f5583dce32af7d4e9925771e581c3cc5ee prerequisite-patch-id: e8f735697c0535afe9335448b16e3e1f308de362 prerequisite-patch-id: eaf1f67c4c07482fb4da81525cbd5dcb1ea2194e prerequisite-patch-id: 9a15aa08fbbbf110ba76409dcc2a3ab5e0764806 prerequisite-patch-id: 675a3c516f47dfcbaf61d5ad41ca7f3babdd3f20 prerequisite-patch-id: ac188cb61957c9639d0ac125c941950afbdba9c7 prerequisite-patch-id: f3f1f02944a4aa9635ce7094bfda254315d990b3 prerequisite-patch-id: 5eee450b2221d67fbda1e6581d16628394c912a7 prerequisite-patch-id: bad535152857928abf624dc49dc2b27718d3885e prerequisite-patch-id: 623edc835c2c5dfd8c83dcf32e650cfebea42aa0 prerequisite-patch-id: c0f50259e7fc09455f77dca31113b0b55e955220 prerequisite-patch-id: 9c7c0929a48b103b6b69626dbc86d7744f2f40ad prerequisite-patch-id: 8f8c2af0b856f56c7798a3b79ba90b073bbb382f prerequisite-patch-id: 7d88402829a8967c23650dffe115a94ae26433da prerequisite-patch-id: ffb3d6215a89195f6e0f274f2f119c1f7b65259a prerequisite-patch-id: 54eec153e523b58c3670c48afda9ef50ec44eb8e prerequisite-patch-id: bc5dfc06e9d67d10a37fbd7ba61939907d93ca7c prerequisite-patch-id: f85cc1c9eac0d44f40afe2a547ac3d866769f685 prerequisite-patch-id: 0db9692e872bf73242cfec6f8aa390abe14d08f1 prerequisite-patch-id: 36431a656d29e90e8eb218730c64807e2477c9d7 prerequisite-patch-id: 6817d73f5e42ccd33b19642ea4ef62814ad2b10e prerequisite-patch-id: 9146aec4a40f7da60a4c64643a9aa0e405567b04 prerequisite-patch-id: ff2daf978d58ec12c25dcbce4e7ee010d337cd54 prerequisite-patch-id: c88d74073fcd5d1ff19a4a9338b0df63b648d98a prerequisite-patch-id: 3032f2193b95d5cb625e33daec015f3354f01903 -- 2.33.0