Received: (at 49671) by debbugs.gnu.org; 19 Mar 2026 16:47:19 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Mar 19 12:47:19 2026
Received: from localhost ([127.0.0.1]:48540 helo=debbugs.gnu.org)
by debbugs.gnu.org with esmtp (Exim 4.84_2)
(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
id 1w3GWl-0000uf-88
for submit <at> debbugs.gnu.org; Thu, 19 Mar 2026 12:47:19 -0400
Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]:60480)
by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
(Exim 4.84_2) (envelope-from <zimon.toutoune@HIDDEN>)
id 1w3GWh-0000uI-S5
for 49671 <at> debbugs.gnu.org; Thu, 19 Mar 2026 12:47:16 -0400
Received: by mail-wm1-x331.google.com with SMTP id
5b1f17b1804b1-486507134e4so14114505e9.0
for <49671 <at> debbugs.gnu.org>; Thu, 19 Mar 2026 09:47:15 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20230601; t=1773938835; x=1774543635; darn=debbugs.gnu.org;
h=content-transfer-encoding:mime-version:user-agent:message-id:date
:references:in-reply-to:subject:cc:to:from:from:to:cc:subject:date
:message-id:reply-to;
bh=HHxE0lKWEg742kriVIoQCVRVLvm3WHI65ybWHg98qTM=;
b=IpdNwW3H4V/ixT1QQpnRnlbMWdziQU7+zD3UY0FVSLF1BNl6jxf7AAbMaUhjfEV7c7
qg2x5VcaK1uTI6K82naOJzlQ7HXvzoFj6w0UZDWyt8HtgE02LLHB9CyBulb6/CxJ2jpS
nF0FQQfranup+9EpcojvnwnF03uiYtlKNTlviOFmQsR/ZZWQhs8a4RwtktE0AAtyggm6
4INOgw0gil+kZTomuW/qSwBv4SCUlE6/e4qpY9jgc3LD962tVCcCBvd3hHTcPETKzELx
JqDFoYwYDe6QzFTUE6z6YINNSvwgX1BGET86mLs/hwSmK34UYLpAUtT8QS36VbI/gifW
pt4g==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20251104; t=1773938835; x=1774543635;
h=content-transfer-encoding:mime-version:user-agent:message-id:date
:references:in-reply-to:subject:cc:to:from:x-gm-gg
:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;
bh=HHxE0lKWEg742kriVIoQCVRVLvm3WHI65ybWHg98qTM=;
b=Bq8gxZaYA92AU7jGt1Ny9TNTkLHqZgYTAABNT+jyijjWRmSHbIdRhFn6YXDuISVBQ5
RFPVB9pOCKf/2/GzsPPCV98qtTtsb5Bjk3pKcZt7noWIjR1VqZdHeyNF9NTt+qSIFsQu
2CjzXvgnUZBzHjZtRKo52aWvWsLO/kQcNpt8Y793Nh1PfE4fgdcBzFLKslIV6XvXy18k
uQJzFljY/gErAiFoIOQh0F90kQRNZMigdUFRcGamIdyiAP3WQVRk8/z14YYrtUXGstxQ
9fOM25QFiG8psiY7yN/5ze6DZkmvq1KCEhLjrMXoXokTF08iuBCq0Lsjqh4wIIRpjtDi
021w==
X-Gm-Message-State: AOJu0YwnuZ6Bp3SxWYzqkLd0SHSaP54qwPJIavAkJtve7M8iOPOiFm37
NxLUdaBERQCWWhXEcQxKo3UhXgtZqExNvhqlHMOi76BFmbhccBPOP5iVWs+eqQ==
X-Gm-Gg: ATEYQzyAGvvTDomk4W39/Tf9BK/ikmcgaJ+yCiC8WOtKMmU8OZeVesztW9RTf+V9g7W
sn8HWva84dSlorLbFMyPTjOeY/v870cicateOS1H5B/IsYFNST+5sXL1Wra/oEKmDCCK4/qH2tO
oO0lZVwcddQXjaib60j0qo4gb+MPAvIvLvgJV63imZFHaIQ2d0D0J6BNYZM4EX81oqiY4kvjd/7
qWSeo5ARKs8a+EA036DnFKsA0XNV8eRh6ymGea303DBxzW+FJ4e4QW3ZPrvL+kabHHZyl7840Dm
1R9u+Yz3+NfE1ve2cLsRwB4yBX7JIM+Pf45A8jbgwDj2r9zJnwzE6z97eveCASkYFke1ZE/tuc8
3iXX+tDtzHeiVutKww8ksgkzz6P0zQndaYh84HdIqrfTQf0448PbFeQnsf9PS0jUG9h/ZN2r7dJ
tmdLoad8ohMbb4mLZGIbIQYHRreO7MI1lwSyiBZfmarGuAxNPf63HfuymWxCU=
X-Received: by 2002:a05:600c:5303:b0:486:fc3b:3e61 with SMTP id
5b1f17b1804b1-486fc3b4071mr41033895e9.18.1773938834313;
Thu, 19 Mar 2026 09:47:14 -0700 (PDT)
Received: from lili (nat-dsi-209.net.univ-paris-diderot.fr. [81.194.30.209])
by smtp.gmail.com with ESMTPSA id
5b1f17b1804b1-486fe8367d8sm1414385e9.14.2026.03.19.09.47.12
(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
Thu, 19 Mar 2026 09:47:13 -0700 (PDT)
From: Simon Tournier <zimon.toutoune@HIDDEN>
To: Julien Lepiller <julien@HIDDEN>
Subject: Re: bug#49671: [PATCH] guix: records: Improve error reporting.
In-Reply-To: <20220717082339.665a7385@HIDDEN> (Julien Lepiller's
message of "Sun, 17 Jul 2022 08:23:39 +0200")
References: <20210721014047.3878a0c7@HIDDEN>
<20211031030635.520a3c6c@HIDDEN>
<20211122034022.152daf55@HIDDEN>
<20220717082339.665a7385@HIDDEN>
Date: Thu, 19 Mar 2026 17:29:24 +0100
Message-ID: <87wlz7eqaj.fsf_-_@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: 1.0 (+)
X-Debbugs-Envelope-To: 49671
Cc: 49671 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: 0.0 (/)
Hi Julien
For more context, see:
https://issues.guix.gnu.org/issue/49671
=20=20=20=20
On Sun, 17 Jul 2022 at 08:23, Julien Lepiller <julien@HIDDEN> wrote:
> A few months have passed without comment. I don't feel confident enough
> to change Guix internals without comments.
Well, now it=E2=80=99s 3 years and 35 weeks later=E2=80=A6 What is the sta=
tus of this
patch?
Maybe it could be worth to rebase on the top of master and resubmit to
Codeberg <https://codeberg.org/guix/guix>. It will get the attention it
deserves. :-)
Cheers,
simon
guix-patches@HIDDEN:bug#49671; Package guix-patches.
Full text available.Received: (at 49671) by debbugs.gnu.org; 17 Jul 2022 06:23:57 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Sun Jul 17 02:23:57 2022 Received: from localhost ([127.0.0.1]:46565 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1oCxh3-00076P-9O for submit <at> debbugs.gnu.org; Sun, 17 Jul 2022 02:23:57 -0400 Received: from lepiller.eu ([89.234.186.109]:44430) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <julien@HIDDEN>) id 1oCxgw-000769-4Y for 49671 <at> debbugs.gnu.org; Sun, 17 Jul 2022 02:23:51 -0400 Received: from lepiller.eu (localhost [127.0.0.1]) by lepiller.eu (OpenSMTPD) with ESMTP id e4158c5d for <49671 <at> debbugs.gnu.org>; Sun, 17 Jul 2022 06:23:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=lepiller.eu; h=date:from :to:subject:message-id:in-reply-to:references:mime-version :content-type:content-transfer-encoding; s=dkim; bh=FiHbgNJe6Sam wDZI/Mke0BsHdqsWtI3KH2+YyB0h70U=; b=g67ai+OuXJCiTQCPF/aewt/3jN2r qD+oyMr9G7B/3GFHH05RGVV7mfsUX9TCisXyeCoM7QMpv72LpZ1kv4ApKFm3CI7h Ioha4ODZ5BV0ye6qf9zc969Gm/o3Vdivy4VkP9SzXvv4+oFrhJlaZN+e4ETOb4vD m1daLemwga6eA2XJXbGNM2hf7mhgyQ8l2RHRG3n95FUXickm56ElE/99IqEZkkG2 W7BNvdbNVH1yV26RjVj7ejw6ycUOQZXr4h8uAU7F5+TvzeKgEaEb+sG+XnkoKuSS 0tBHTR8sjk55mzlnPYn/QMSsNFfr0ls/rW0noQ7NkmnLvq1qD5FFKDiHKg== Received: by lepiller.eu (OpenSMTPD) with ESMTPSA id 03f23e40 (TLSv1.3:AEAD-AES256-GCM-SHA384:256:NO) for <49671 <at> debbugs.gnu.org>; Sun, 17 Jul 2022 06:23:42 +0000 (UTC) Date: Sun, 17 Jul 2022 08:23:39 +0200 From: Julien Lepiller <julien@HIDDEN> To: 49671 <at> debbugs.gnu.org Subject: Re: [bug#49671] [PATCH v3] guix: records: Improve error reporting. Message-ID: <20220717082339.665a7385@HIDDEN> In-Reply-To: <20211122034022.152daf55@HIDDEN> References: <20210721014047.3878a0c7@HIDDEN> <20211031030635.520a3c6c@HIDDEN> <20211122034022.152daf55@HIDDEN> X-Mailer: Claws Mail 4.0.0 (GTK+ 3.24.30; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 49671 X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) Hi Guix! A few months have passed without comment. I don't feel confident enough to change Guix internals without comments. What are your thoughts on this? Le Mon, 22 Nov 2021 03:40:22 +0100, Julien Lepiller <julien@HIDDEN> a =C3=A9crit : > Here is another improvement compared to v2. This time there are two > patches: the first adds support for &syntax in (guix ui), and will > print something like >=20 > in form: <pretty-printed-form> >=20 > where "in form" is in green. >=20 > The second patch is very similar to v2, but will now also raise a > &syntax condition, so it can be pretty-printed. The previous issue > where I printed #<syntax ...> is fixed, I simply forgot a > syntax->datum. >=20 > WDYT?
guix-patches@HIDDEN:bug#49671; Package guix-patches.
Full text available.
Received: (at 49671) by debbugs.gnu.org; 22 Nov 2021 02:40:35 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Nov 21 21:40:35 2021
Received: from localhost ([127.0.0.1]:46462 helo=debbugs.gnu.org)
by debbugs.gnu.org with esmtp (Exim 4.84_2)
(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
id 1mozFy-0000va-LP
for submit <at> debbugs.gnu.org; Sun, 21 Nov 2021 21:40:35 -0500
Received: from lepiller.eu ([89.234.186.109]:40274)
by debbugs.gnu.org with esmtp (Exim 4.84_2)
(envelope-from <julien@HIDDEN>) id 1mozFv-0000vQ-PL
for 49671 <at> debbugs.gnu.org; Sun, 21 Nov 2021 21:40:33 -0500
Received: from lepiller.eu (localhost [127.0.0.1])
by lepiller.eu (OpenSMTPD) with ESMTP id 0fb7133e
for <49671 <at> debbugs.gnu.org>; Mon, 22 Nov 2021 02:40:29 +0000 (UTC)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=lepiller.eu; h=date:from
:to:subject:message-id:in-reply-to:references:mime-version
:content-type; s=dkim; bh=iGD6lU7sHEq64YvvtH8vPHWZeUwfOdHKzjJUAW
Ww3aw=; b=Ba28/Xa2ZhHZ0BeOM6F0bIV55BrRVZRct9N8yrQVxdRHHgUuUgkCJZ
gbHNIP+0bXWLXUel/TXoIK6lSbctWVKh++32+cezu1RYhqRXjov+8VnNu4xfI2Eq
cwc6yx2yuSiS7iJNr3iAA5I5D/mdE4wc9ffQegt1gtUX0VkCd3EPDkkx/3e3y2r5
qwMJj3aOvhUgVSlS2F6yGjMETOmBPC/VZhnUliPcb8BotIlqJ/NnLmMJLw5IHP+1
2qQgA7T8iXF40ozQNCJEmiprAwUX813uYa5Ylbc/iSl8ToAQ9gI630x4XXObNx3O
S4HweRrIFKoXcplW0IZzYZP/AzuqGFIw==
Received: by lepiller.eu (OpenSMTPD) with ESMTPSA id 61c83d1c
(TLSv1.3:AEAD-AES256-GCM-SHA384:256:NO) for <49671 <at> debbugs.gnu.org>;
Mon, 22 Nov 2021 02:40:29 +0000 (UTC)
Date: Mon, 22 Nov 2021 03:40:22 +0100
From: Julien Lepiller <julien@HIDDEN>
To: 49671 <at> debbugs.gnu.org
Subject: Re: [bug#49671] [PATCH v3] guix: records: Improve error reporting.
Message-ID: <20211122034022.152daf55@HIDDEN>
In-Reply-To: <20211031030635.520a3c6c@HIDDEN>
References: <20210721014047.3878a0c7@HIDDEN>
<20211031030635.520a3c6c@HIDDEN>
X-Mailer: Claws Mail 4.0.0 (GTK+ 3.24.24; x86_64-pc-linux-gnu)
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="MP_/O=5syjF3.pIA+c2Heao74c0"
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 49671
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)
--MP_/O=5syjF3.pIA+c2Heao74c0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
Here is another improvement compared to v2. This time there are two
patches: the first adds support for &syntax in (guix ui), and will
print something like
in form: <pretty-printed-form>
where "in form" is in green.
The second patch is very similar to v2, but will now also raise a
&syntax condition, so it can be pretty-printed. The previous issue
where I printed #<syntax ...> is fixed, I simply forgot a syntax->datum.
WDYT?
--MP_/O=5syjF3.pIA+c2Heao74c0
Content-Type: text/x-patch
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename=0001-guix-ui-Print-syntax-errors.patch
From d1d857ea0ca76f1a917382777f57871e50026df3 Mon Sep 17 00:00:00 2001
Message-Id: <d1d857ea0ca76f1a917382777f57871e50026df3.1637548566.git.julien@HIDDEN>
From: Julien Lepiller <julien@HIDDEN>
Date: Mon, 22 Nov 2021 02:54:06 +0100
Subject: [PATCH 1/2] guix: ui: Print syntax errors.
* guix/ui.scm (display-syntax): New procedure.
(call-with-error-handling, report-load-error): Print syntax errors.
---
guix/ui.scm | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/guix/ui.scm b/guix/ui.scm
index bd999103ff..79aab2db84 100644
--- a/guix/ui.scm
+++ b/guix/ui.scm
@@ -69,9 +69,11 @@ (define-module (guix ui)
#:use-module (srfi srfi-31)
#:use-module (srfi srfi-34)
#:use-module (srfi srfi-35)
+ #:use-module (ice-9 exceptions)
#:autoload (ice-9 ftw) (scandir)
#:use-module (ice-9 match)
#:use-module (ice-9 format)
+ #:use-module (ice-9 pretty-print)
#:use-module (ice-9 regex)
#:autoload (ice-9 popen) (open-pipe* close-pipe)
#:autoload (system repl repl) (start-repl)
@@ -315,6 +317,19 @@ (define* (display-hint message #:optional (port (current-error-port)))
(texi->plain-text message))
port))
+(define %syntax-color (color BOLD GREEN))
+
+(define* (display-syntax form #:optional (port (current-error-port)))
+ "Display FORM, an sexp, to PORT"
+ (define colorize
+ (if (color-output? port)
+ (lambda (str)
+ (colorize-string str %syntax-color))
+ identity))
+
+ (display (colorize (G_ "in form: ")) port)
+ (pretty-print form port))
+
(define* (report-unbound-variable-error args #:key frame)
"Return the given unbound-variable error, where ARGS is the list of 'throw'
arguments."
@@ -398,6 +413,9 @@ (define* (report-load-error file args #:optional frame)
(formatted-message-arguments obj)))
(else
(report-error (G_ "exception thrown: ~s~%") obj)))
+ (when (syntax-error? obj)
+ (let ((form (or (syntax-error-subform obj) (syntax-error-form obj))))
+ (display-syntax form)))
(when (fix-hint? obj)
(display-hint (condition-fix-hint obj))))
((key args ...)
@@ -801,6 +819,9 @@ (define (call-with-error-handling thunk)
(and (error-location? c) (error-location c))
(gettext (formatted-message-string c) %gettext-domain)
(formatted-message-arguments c))
+ (when (syntax-error? c)
+ (let ((form (or (syntax-error-subform c) (syntax-error-form c))))
+ (display-syntax form)))
(when (fix-hint? c)
(display-hint (condition-fix-hint c)))
(exit 1))
@@ -826,6 +847,9 @@ (define (call-with-error-handling thunk)
(report-error (and (error-location? c) (error-location c))
(G_ "~a~%")
(gettext (condition-message c) %gettext-domain))
+ (when (syntax-error? c)
+ (let ((form (or (syntax-error-subform c) (syntax-error-form c))))
+ (display-syntax form)))
(when (fix-hint? c)
(display-hint (condition-fix-hint c)))
(exit 1)))
--
2.33.1
--MP_/O=5syjF3.pIA+c2Heao74c0
Content-Type: text/x-patch
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
filename=0002-guix-records-Improve-error-reporting.patch
=46rom 2eebd1113a40fc6e7018975d3696546de584e4a0 Mon Sep 17 00:00:00 2001
Message-Id: <2eebd1113a40fc6e7018975d3696546de584e4a0.1637548566.git.julien=
@lepiller.eu>
In-Reply-To: <d1d857ea0ca76f1a917382777f57871e50026df3.1637548566.git.julie=
n@HIDDEN>
References: <d1d857ea0ca76f1a917382777f57871e50026df3.1637548566.git.julien=
@lepiller.eu>
From: Julien Lepiller <julien@HIDDEN>
Date: Sun, 31 Oct 2021 02:58:14 +0100
Subject: [PATCH 2/2] guix: records: Improve error reporting.
* guix/records.scm (report-invalid-field-specifier): Handle various
invalidity causes separately.
---
guix/records.scm | 56 ++++++++++++++++++++++++++++++++++++++++++++----
1 file changed, 52 insertions(+), 4 deletions(-)
diff --git a/guix/records.scm b/guix/records.scm
index ed94c83dac..eeb5908844 100644
--- a/guix/records.scm
+++ b/guix/records.scm
@@ -1,6 +1,7 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright =C2=A9 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020,=
2021 Ludovic Court=C3=A8s <ludo@HIDDEN>
;;; Copyright =C2=A9 2018 Mark H Weaver <mhw@HIDDEN>
+;;; Copyright =C2=A9 2021 Julien Lepiller <julien@HIDDEN>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -21,9 +22,13 @@ (define-module (guix records)
#: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)
+ #:use-module (guix diagnostics)
+ #:use-module (guix ui)
#:autoload (system base target) (target-most-positive-fixnum)
#:export (define-record-type*
this-record
@@ -83,10 +88,53 @@ (define-syntax record-error
;; WEIRD may be an identifier, thus lacking source location info,=
and
;; BINDINGS is a list, also lacking source location info. Hopefu=
lly
;; PARENT-FORM provides source location info.
- (apply syntax-violation name "invalid field specifier"
- (if parent-form
- (list parent-form #'weird)
- (list #'weird)))))))
+ (let* ((weird-properties (source-properties #'weird))
+ (parent-properties (and parent-form (syntax-source parent-=
form)))
+ (form parent-form)
+ (location (source-properties->location
+ (or (and (not (null? weird-properties)) weird-=
properties)
+ (and (not (null? parent-properties)) paren=
t-properties)
+ '()))))
+ (syntax-case #'weird ()
+ (() ;the empty list
+ (raise-exception
+ (condition
+ (&message (message (G_ "invalid field specifier.")))
+ (&syntax (form form) (subform (syntax->datum #'weird)))
+ (&error-location (location location))
+ (&fix-hint (hint (G_ "The format of a field is `(field v=
alue)'"))))))
+ (((field ...) _ ...) ;a list whose first element i=
s a list
+ (raise-exception
+ (condition
+ (&message (message (G_ "invalid field name.")))
+ (&syntax (form form) (subform (map syntax->datum #'(fiel=
d ...))))
+ (&error-location (location location)))))
+ ((field) ;a list with one element
+ (raise-exception
+ (condition
+ (&message (message (G_ "missing value in field specifier=
.")))
+ (&syntax (form form) (subform (syntax->datum #'weird)))
+ (&error-location (location location))
+ (&fix-hint (hint (format #f (G_ "The field is missing a =
value: `(~a <value>)'.")
+ (syntax->datum #'field)))))))
+ ((field value ...) ;any other list
+ (raise-exception
+ (condition
+ (&message (message (G_ "multiple values in field specifi=
er.")))
+ (&syntax (form form) (subform (syntax->datum #'weird)))
+ (&error-location (location location))
+ (&fix-hint (hint (format #f (G_ "~a values were associat=
ed with \
+field `~a'. Perhaps the additional values were intended to be other field=
\
+specifiers. This usually indicates missing or misplaced parenthesis.")
+ (length #'(value ...))
+ (syntax->datum #'field)))))))
+ (field ;not a list
+ (raise-exception
+ (condition
+ (&message (message (G_ "invalid field specifier.")))
+ (&syntax (form form) (subform (syntax->datum #'weird)))
+ (&error-location (location location))
+ (&fix-hint (hint (G_ "The format of a field is `(field v=
alue)'"))))))))))))
=20
(define (report-duplicate-field-specifier name ctor)
"Report the first duplicate identifier among the bindings in CTOR."
--=20
2.33.1
--MP_/O=5syjF3.pIA+c2Heao74c0--
guix-patches@HIDDEN:bug#49671; Package guix-patches.
Full text available.
Received: (at 49671) by debbugs.gnu.org; 31 Oct 2021 02:06:52 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Oct 30 22:06:52 2021
Received: from localhost ([127.0.0.1]:58711 helo=debbugs.gnu.org)
by debbugs.gnu.org with esmtp (Exim 4.84_2)
(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
id 1mh0FH-0001Q1-JE
for submit <at> debbugs.gnu.org; Sat, 30 Oct 2021 22:06:52 -0400
Received: from lepiller.eu ([89.234.186.109]:37270)
by debbugs.gnu.org with esmtp (Exim 4.84_2)
(envelope-from <julien@HIDDEN>) id 1mh0FC-0001Pl-Jh
for 49671 <at> debbugs.gnu.org; Sat, 30 Oct 2021 22:06:49 -0400
Received: from lepiller.eu (localhost [127.0.0.1])
by lepiller.eu (OpenSMTPD) with ESMTP id b31e2f7e
for <49671 <at> debbugs.gnu.org>; Sun, 31 Oct 2021 02:06:42 +0000 (UTC)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=lepiller.eu; h=date:from
:to:subject:message-id:mime-version:content-type; s=dkim; bh=aUq
HEZ0OtEw2e9Iz6TavwSjSwxhAkChHvn1GtsYsQeI=; b=OPiqCVpue3rwqc8AEYU
4G/wszXG3psKLHYG0m6ho3WLPX/vaT+5tKCP6ddT53791iTLYC0cjRuQvGLAVB4g
AqRa0sJgSFdARhoziQEoeZGCbzCiFiE43B68ME3u3NYbDSiL7Hw4c+b1Y9+jdeor
OHh/F/fhXAwFhCJpZCY2Pdjq8CghB1LoLwcdXibPV2iN+2iHp5wELny5mjOUHzpo
NODM6rjgTD9tfO6ZwDw7z7fc0/UnfboCJn3S8ekcK00vbOSNu5Vg8kLTqhKPdvIG
n2/cUWFDv0juY+HLWY+KbwF6MS3f/IJO/cDnBGKTRVzJzdImZn2zNbfeRaNN02gS
UAw==
Received: by lepiller.eu (OpenSMTPD) with ESMTPSA id 107fcaa5
(TLSv1.3:AEAD-AES256-GCM-SHA384:256:NO) for <49671 <at> debbugs.gnu.org>;
Sun, 31 Oct 2021 02:06:42 +0000 (UTC)
Date: Sun, 31 Oct 2021 03:06:35 +0100
From: Julien Lepiller <julien@HIDDEN>
To: 49671 <at> debbugs.gnu.org
Subject: [PATCH] guix: records: Improve error reporting.
Message-ID: <20211031030635.520a3c6c@HIDDEN>
X-Mailer: Claws Mail 4.0.0 (GTK+ 3.24.24; x86_64-pc-linux-gnu)
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="MP_/weRgIw/4gs/j4Y4tHo+voqE"
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 49671
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)
--MP_/weRgIw/4gs/j4Y4tHo+voqE
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
Hi Guix!
Here is a new patch that attempts to better catch various causes of
syntax errors in records. I think I fixed all the concerns Ludo had,
and I draw some inspiration from https://issues.guix.gnu.org/50914 for
using conditions.
Here are examples of what you get:
(operating-system
())
test.scm:1:0: error: invalid field specifier: ()
hint: The format of a field is `(field value)'
(operating-system
((services %base-services)))
test.scm:1:0: error: invalid field specifier: (services %base-services)
is not a valid field name
(operating-system
(services))
test.scm:1:0: error: missing value in field specifier
hint: The field is missing a value: `(services <value>)'.
(operating-system
(services (service tor-service-type) %base-services))
test.scm:1:0: error: multiple values in field specifier
hint: 2 values were associated with field `services'. We got the
following values:
(service tor-service-type)
%base-services
Perhaps the additional values were intended to be other field
specifiers. This usually indicates missing or misplaced parenthesis.
(operating-system
services %base-services)
test.scm:1:0: error: invalid field specifier: #<syntax services>
hint: The format of a field is `(field value)'
(not sure why the last one is wrapped in syntax...)
--MP_/weRgIw/4gs/j4Y4tHo+voqE
Content-Type: text/x-patch
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
filename=0001-guix-records-Improve-error-reporting.patch
=46rom 9e08a887a08da3f0cc132d148b748eb2ce7db135 Mon Sep 17 00:00:00 2001
Message-Id: <9e08a887a08da3f0cc132d148b748eb2ce7db135.1635645523.git.julien=
@lepiller.eu>
From: Julien Lepiller <julien@HIDDEN>
Date: Sun, 31 Oct 2021 02:58:14 +0100
Subject: [PATCH] guix: records: Improve error reporting.
* guix/records.scm (report-invalid-field-specifier): Handle various
invalidity causes separately.
---
guix/records.scm | 56 ++++++++++++++++++++++++++++++++++++++++++++----
1 file changed, 52 insertions(+), 4 deletions(-)
diff --git a/guix/records.scm b/guix/records.scm
index ed94c83dac..9baa2c2f1d 100644
--- a/guix/records.scm
+++ b/guix/records.scm
@@ -1,6 +1,7 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright =C2=A9 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020,=
2021 Ludovic Court=C3=A8s <ludo@HIDDEN>
;;; Copyright =C2=A9 2018 Mark H Weaver <mhw@HIDDEN>
+;;; Copyright =C2=A9 2021 Julien Lepiller <julien@HIDDEN>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -21,9 +22,13 @@ (define-module (guix records)
#:use-module (srfi srfi-1)
#:use-module (srfi srfi-9)
#:use-module (srfi srfi-26)
+ #:use-module (srfi srfi-35)
+ #:use-module (ice-9 format)
#:use-module (ice-9 match)
#:use-module (ice-9 regex)
#:use-module (ice-9 rdelim)
+ #:use-module (guix diagnostics)
+ #:use-module (guix ui)
#:autoload (system base target) (target-most-positive-fixnum)
#:export (define-record-type*
this-record
@@ -83,10 +88,53 @@ (define-syntax record-error
;; WEIRD may be an identifier, thus lacking source location info,=
and
;; BINDINGS is a list, also lacking source location info. Hopefu=
lly
;; PARENT-FORM provides source location info.
- (apply syntax-violation name "invalid field specifier"
- (if parent-form
- (list parent-form #'weird)
- (list #'weird)))))))
+ (let* ((weird-properties (source-properties #'weird))
+ (parent-properties (and parent-form (syntax-source parent-=
form)))
+ (location (source-properties->location
+ (or (and (not (null? weird-properties)) weird-=
properties)
+ (and (not (null? parent-properties)) paren=
t-properties)
+ '()))))
+ (syntax-case #'weird ()
+ (() ;the empty list
+ (raise-exception
+ (condition
+ (&message (message (format #f (G_ "invalid field specifi=
er: ~a")
+ #'weird)))
+ (&error-location (location location))
+ (&fix-hint (hint (G_ "The format of a field is `(field v=
alue)'"))))))
+ (((field ...) _ ...) ;a list whose first element i=
s a list
+ (raise-exception
+ (condition
+ (&message (message (format #f (G_ "invalid field specifi=
er: ~a \
+is not a valid field name")
+ (map syntax->datum #'(field .=
..)))))
+ (&error-location (location location)))))
+ ((field) ;a list with one element
+ (raise-exception
+ (condition
+ (&message (message (G_ "missing value in field specifier=
")))
+ (&error-location (location location))
+ (&fix-hint (hint (format #f (G_ "The field is missing a =
value: `(~a <value>)'.")
+ (syntax->datum #'field)))))))
+ ((field value ...) ;any other list
+ (raise-exception
+ (condition
+ (&message (message (G_ "multiple values in field specifi=
er")))
+ (&error-location (location location))
+ (&fix-hint (hint (format #f (G_ "~a values were associat=
ed with \
+field `~a'. We got the following values:~%@lisp~%~{~a~%~}~%@end lisp~%Per=
haps the additional values
+were intended to be other field specifiers. This usually indicates missin=
g or \
+misplaced parenthesis.")
+ (length #'(value ...))
+ (syntax->datum #'field)
+ (map syntax->datum #'(value ...=
))))))))
+ (field ;not a list
+ (raise-exception
+ (condition
+ (&message (message (format #f (G_ "invalid field specifi=
er: ~a")
+ #'weird)))
+ (&error-location (location location))
+ (&fix-hint (hint (G_ "The format of a field is `(field v=
alue)'"))))))))))))
=20
(define (report-duplicate-field-specifier name ctor)
"Report the first duplicate identifier among the bindings in CTOR."
--=20
2.33.1
--MP_/weRgIw/4gs/j4Y4tHo+voqE--
guix-patches@HIDDEN:bug#49671; Package guix-patches.
Full text available.Received: (at 49671) by debbugs.gnu.org; 4 Oct 2021 14:26:45 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Mon Oct 04 10:26:45 2021 Received: from localhost ([127.0.0.1]:38050 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1mXOvV-0005ZW-Ft for submit <at> debbugs.gnu.org; Mon, 04 Oct 2021 10:26:45 -0400 Received: from eggs.gnu.org ([209.51.188.92]:45448) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <ludo@HIDDEN>) id 1mXOvT-0005ZD-As; Mon, 04 Oct 2021 10:26:43 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:55938) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from <ludo@HIDDEN>) id 1mXOvM-0008E6-MI; Mon, 04 Oct 2021 10:26:37 -0400 Received: from [2001:660:6102:320:e120:2c8f:8909:cdfe] (port=60564 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <ludo@HIDDEN>) id 1mXOvM-0003s2-Ao; Mon, 04 Oct 2021 10:26:36 -0400 From: =?utf-8?Q?Ludovic_Court=C3=A8s?= <ludo@HIDDEN> To: Maxime Devos <maximedevos@HIDDEN> Subject: Re: bug#50914: [PATCH] records: Raise a &fix-hint if a field has multiple values. References: <20210930093229.4730-1-maximedevos@HIDDEN> Date: Mon, 04 Oct 2021 16:26:33 +0200 In-Reply-To: <20210930093229.4730-1-maximedevos@HIDDEN> (Maxime Devos's message of "Thu, 30 Sep 2021 11:32:29 +0200") Message-ID: <87r1d0ooh2.fsf@HIDDEN> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 49671 Cc: 49671 <at> debbugs.gnu.org, 50914 <at> debbugs.gnu.org X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -3.3 (---) Hi, Maxime Devos <maximedevos@HIDDEN> skribis: > * guix/records.scm (report-invalid-field-specifier): If > 'weird' is something like (field (record ...) extra ...), hint that 'ex= tra > ...' should probably be moved inside (record ...). Please see also <https://issues.guix.gnu.org/49671>. > + (condition > + (&origin (origin name)) > + (&message (message > + (format #f "field =E2=80=98~a=E2=80=99 should= only have one \ > +value, but an extra value =E2=80=98~a=E2=80=99 was passed as well. Perh= aps this extra \ > +value was supposed to be a field specifier, and needs to be moved inside= \ > +the record =E2=80=98~a=E2=80=99?" We=E2=80=99ll need i18n here and straight quotes. > + (&syntax (form (car forms)) > + (subform (and (not (null? (cdr forms))) > + (cadr forms)))) No cadrcdr please. :-) > + (&fix-hint (hint (object->string > + (syntax->datum > + #'(field > + (record-name fields ... extra-value > + extra-value* ...)))))= )))) The =E2=80=98hint=E2=80=99 field must be a string, typically the message yo= u had above; see other examples in the code. TIA! Ludo=E2=80=99.
guix-patches@HIDDEN:bug#49671; Package guix-patches.
Full text available.
Received: (at 49671) by debbugs.gnu.org; 4 Aug 2021 15:20:01 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Aug 04 11:20:01 2021
Received: from localhost ([127.0.0.1]:44942 helo=debbugs.gnu.org)
by debbugs.gnu.org with esmtp (Exim 4.84_2)
(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
id 1mBIga-0008J3-Nu
for submit <at> debbugs.gnu.org; Wed, 04 Aug 2021 11:20:00 -0400
Received: from eggs.gnu.org ([209.51.188.92]:33762)
by debbugs.gnu.org with esmtp (Exim 4.84_2)
(envelope-from <ludo@HIDDEN>) id 1mBIgY-0008Ir-Ou
for 49671 <at> debbugs.gnu.org; Wed, 04 Aug 2021 11:19:59 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e]:34204)
by eggs.gnu.org with esmtp (Exim 4.90_1)
(envelope-from <ludo@HIDDEN>)
id 1mBIgQ-0004C3-P3; Wed, 04 Aug 2021 11:19:50 -0400
Received: from [2001:660:6102:320:e120:2c8f:8909:cdfe] (port=43036 helo=ribbon)
by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
(Exim 4.90_1) (envelope-from <ludo@HIDDEN>)
id 1mBIgP-0001un-Is; Wed, 04 Aug 2021 11:19:50 -0400
From: =?utf-8?Q?Ludovic_Court=C3=A8s?= <ludo@HIDDEN>
To: Julien Lepiller <julien@HIDDEN>
Subject: Re: bug#49671: [PATCH] guix: records: Improve error reporting.
References: <20210721014047.3878a0c7@HIDDEN>
Date: Wed, 04 Aug 2021 17:19:47 +0200
In-Reply-To: <20210721014047.3878a0c7@HIDDEN> (Julien
Lepiller's message of "Wed, 21 Jul 2021 01:40:47 +0200")
Message-ID: <87bl6dp78s.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 49671
Cc: 49671 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)
Hello!
Julien Lepiller <julien@HIDDEN> skribis:
> Here are the cases that are handled and the associated message:
>
> (operating-system
> services)
> guix system: error: services: invalid field specifier. The format of a
> field is `(services value)'
>
> (operating-system
> (services))
> test.scm:2:2: error: (services): Value missing in field specifier. The
> format of a field is `(services value)'.
>
> (operating-system
> (services 1 2 3))
> test.scm:2:2: error: (services 1 2 3): multiple values in field
> specifier. Got 3 values associated with key services. Values are:
> 1
> 2
> 3
>
> (operating-system
> ())
> guix system: error: (): invalid field specifier. The format of a field
> is `(field value)'
>
> (operating-system
> ((services %desktop-services)))
> test.scm:2:2: error: ((services %desktop-services)): invalid field
> specifier. (services %desktop-services) is not a valid field name.
>
>
> Of course, we can improve these error messages, and internationalize
> them.
I like the idea!
I would prefer for error messages to be plain errors, without hints, so:
test.scm:2:2: error: (services 1 2 3): multiple values in field specifier
(Not a sentence, no period.)
But I=E2=80=99d also like to have hints, and ideally all hints should be
reported consistently, via =E2=80=98&fix-hint=E2=80=99 or similar.
Thankfully, we can do that via (guix diagnostics) + SRFI-35/34:
(raise (condition
(&syntax (form 'x) (subform 'y))
(&fix-hint (hint "Consider fixing this."))))
=E2=80=98call-with-error-handling=E2=80=99 in (guix ui) might need to be ad=
justed.
The only downside is that (guix records) would now depend on another
Guix modules, which I tried to avoid so far so it could be more easily
reused elsewhere. But that=E2=80=99s the price to pay to get consistent er=
ror
reports, and I think it=E2=80=99s okay.
Note that =E2=80=98tests/guix-system.sh=E2=80=99 and a couple of other file=
s test exact
error reports, so we=E2=80=99ll have to make sure it still works and possib=
ly
augment the tests.
WDYT?
Thanks,
Ludo=E2=80=99.
guix-patches@HIDDEN:bug#49671; Package guix-patches.
Full text available.
Received: (at 49671) by debbugs.gnu.org; 21 Jul 2021 19:21:31 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Jul 21 15:21:31 2021
Received: from localhost ([127.0.0.1]:38632 helo=debbugs.gnu.org)
by debbugs.gnu.org with esmtp (Exim 4.84_2)
(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
id 1m6Hmd-0008TB-Gl
for submit <at> debbugs.gnu.org; Wed, 21 Jul 2021 15:21:31 -0400
Received: from out0.migadu.com ([94.23.1.103]:61474)
by debbugs.gnu.org with esmtp (Exim 4.84_2)
(envelope-from <iskarian@HIDDEN>) id 1m6Hma-0008T2-9h
for 49671 <at> debbugs.gnu.org; Wed, 21 Jul 2021 15:21:29 -0400
X-Report-Abuse: Please report any abuse attempt to abuse@HIDDEN and
include these headers.
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mgsn.dev; s=key1;
t=1626895287;
h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
to:to:cc:cc:mime-version:mime-version:content-type:content-type:
in-reply-to:in-reply-to:references:references;
bh=gdXPv+8jNSvtGV4MuiX4qeWrT3MmuIX8Wddxkkk6gcM=;
b=MAGZ8S+PICWvzxfTbxhqvaNmYxNLpiyEmvfUCqeyVosPUUh6EUZOCv7GQNYWVi+aJCcYst
7NaXQgEh2dqShRHu7DiSy09Q+dIR+mYp0fe/aXcW/rVvud/U4rfM1xWzuqbzquPEHcJpj0
y/9wfkq/rvEwa3GIp52zUHPyF+Gb8So=
From: Sarah Morgensen <iskarian@HIDDEN>
To: Julien Lepiller <julien@HIDDEN>
Subject: Re: bug#49671: [PATCH] guix: records: Improve error reporting.
References: <20210721014047.3878a0c7@HIDDEN>
Date: Wed, 21 Jul 2021 12:21:23 -0700
In-Reply-To: <20210721014047.3878a0c7@HIDDEN> (Julien
Lepiller's message of "Wed, 21 Jul 2021 01:40:47 +0200")
Message-ID: <86zgufscb0.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-Migadu-Flow: FLOW_OUT
X-Migadu-Auth-User: iskarian@HIDDEN
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 49671
Cc: 49671 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.7 (-)
Hi Julien,
Julien Lepiller <julien@HIDDEN> writes:
> Hi Guix!
>
> This patch improves error reporting a bit when making mistakes in guix
> records. This is motivated by a user getting "invalid field specifier"
> for their whole services field in their os record. With this patches,
> they would have seen:
After applying your patch, I get:
--8<---------------cut here---------------start------------->8---
guix/records.scm:108:19: warning: "multiple values in field specifier. Got ~a values associated with key ~a. Values are:~%~{~a~%~}": unsupported format option ~{, use (ice-9 format) instead
--8<---------------cut here---------------end--------------->8---
After adding `(ice-9 format)` to imports it works as expected. I see
this also applies to package records! This will be great for those
starting to package in Guix.
>
> multiple values in field specifier. Got 2 values associated with key
> services. Values are:
> (append (list (service ...) ...))
> (modify-services %desktop-services ...)
>
> Which would have hinted them at fixing the parenthesis. Or at least, it
> would have saved us some time trying to count them :)
>
> Here are the cases that are handled and the associated message:
>
> (operating-system
> services)
> guix system: error: services: invalid field specifier. The format of a
> field is `(services value)'
>
> (operating-system
> (services))
> test.scm:2:2: error: (services): Value missing in field specifier. The
> format of a field is `(services value)'.
>
> (operating-system
> (services 1 2 3))
> test.scm:2:2: error: (services 1 2 3): multiple values in field
> specifier. Got 3 values associated with key services. Values are:
^ Wrap in `'?
> 1
> 2
> 3
>
> (operating-system
> ())
> guix system: error: (): invalid field specifier. The format of a field
> is `(field value)'
>
> (operating-system
> ((services %desktop-services)))
> test.scm:2:2: error: ((services %desktop-services)): invalid field
> specifier. (services %desktop-services) is not a valid field name.
^ Should this also be wrapped in `'?
Why do some of these messages lose their context and come from `guix
system` instead?
>
> Of course, we can improve these error messages, and internationalize
> them.
>
> WDYT?
[...]
> - (apply syntax-violation name "invalid field specifier"
> - (if parent-form
> + (syntax-case #'weird ()
> + (() ;the empty list
> + (apply syntax-violation name
> + "invalid field specifier. The format of a field is `(field value)'"
> (list parent-form #'weird)
> - (list #'weird)))))))
> + (list #'weird)))
Why the extra `(list #'weird')`? AFAICT right now this is providing
`(list parent-form #:'weird)` as the parent form. And since parent-form
is optional, shouldn't this be
--8<---------------cut here---------------start------------->8---
(apply syntax-violation name
"invalid field specifier. The format of a field is `(field value)'"
(if parent-form (list parent-form #:'weird) (list weird)))
--8<---------------cut here---------------end--------------->8---
(and similar for the others)?
--
Sarah
guix-patches@HIDDEN:bug#49671; Package guix-patches.
Full text available.
Received: (at submit) by debbugs.gnu.org; 20 Jul 2021 23:41:15 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Jul 20 19:41:15 2021
Received: from localhost ([127.0.0.1]:35682 helo=debbugs.gnu.org)
by debbugs.gnu.org with esmtp (Exim 4.84_2)
(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
id 1m5zMQ-0006bi-JL
for submit <at> debbugs.gnu.org; Tue, 20 Jul 2021 19:41:14 -0400
Received: from lists.gnu.org ([209.51.188.17]:52842)
by debbugs.gnu.org with esmtp (Exim 4.84_2)
(envelope-from <julien@HIDDEN>) id 1m5zMO-0006bb-OL
for submit <at> debbugs.gnu.org; Tue, 20 Jul 2021 19:41:13 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:43352)
by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
(Exim 4.90_1) (envelope-from <julien@HIDDEN>)
id 1m5zMN-0006g2-At
for guix-patches@HIDDEN; Tue, 20 Jul 2021 19:41:11 -0400
Received: from lepiller.eu ([2a00:5884:8208::1]:41982)
by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
(Exim 4.90_1) (envelope-from <julien@HIDDEN>)
id 1m5zMJ-0005sI-Dg
for guix-patches@HIDDEN; Tue, 20 Jul 2021 19:41:10 -0400
Received: from lepiller.eu (localhost [127.0.0.1])
by lepiller.eu (OpenSMTPD) with ESMTP id 3e99d9b3
for <guix-patches@HIDDEN>; Tue, 20 Jul 2021 23:41:00 +0000 (UTC)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=lepiller.eu; h=date:from
:to:subject:message-id:mime-version:content-type; s=dkim; bh=Jzv
L5p/FEwCJ8aKOL34W4e/+7g+irLG2mi7B79llZOo=; b=R4CRQysHkDD5S/eZfR2
rYy2QmQfl8P5+3YLV+ZDkniK4wcw7vEEt0pt3JdK2m8or/KVvPFueX+R8E1tznfe
Y9e66xsIS3Mr0th51irTcVEuYWB9fllC/810K36rGPquuATaVnp8+ko8VboStIgK
CQtHdawfzaCwJass2+dNVEc/vRHGqHd8lPJzc3DGTZSGxvJ1KGCoMg6fKGtM6d0e
Jjv+UkHZLxOQHllGmOdyTPQborpi/F6jn61Uzwrb+ZlrG4WD4IEnHoWr8qveyAuU
UTYrKQAf/s7cWBc1M5UhM3IQieoxnzAN+VyUPMrk/cJFJsOMj6MJjuisF7Q1WDiD
fHQ==
Received: by lepiller.eu (OpenSMTPD) with ESMTPSA id acbfdb09
(TLSv1.3:AEAD-AES256-GCM-SHA384:256:NO) for <guix-patches@HIDDEN>;
Tue, 20 Jul 2021 23:41:00 +0000 (UTC)
Date: Wed, 21 Jul 2021 01:40:47 +0200
From: Julien Lepiller <julien@HIDDEN>
To: guix-patches@HIDDEN
Subject: [PATCH] guix: records: Improve error reporting.
Message-ID: <20210721014047.3878a0c7@HIDDEN>
X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.32; x86_64-pc-linux-gnu)
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="MP_/e6eTRR3_p7yxMS_Ql97axbF"
Received-SPF: pass client-ip=2a00:5884:8208::1;
envelope-from=julien@HIDDEN; helo=lepiller.eu
X-Spam_score_int: -20
X-Spam_score: -2.1
X-Spam_bar: --
X-Spam_report: (-2.1 / 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, SPF_HELO_PASS=-0.001,
SPF_PASS=-0.001 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: -1.3 (-)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.3 (--)
--MP_/e6eTRR3_p7yxMS_Ql97axbF
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
Hi Guix!
This patch improves error reporting a bit when making mistakes in guix
records. This is motivated by a user getting "invalid field specifier"
for their whole services field in their os record. With this patches,
they would have seen:
multiple values in field specifier. Got 2 values associated with key
services. Values are:
(append (list (service ...) ...))
(modify-services %desktop-services ...)
Which would have hinted them at fixing the parenthesis. Or at least, it
would have saved us some time trying to count them :)
Here are the cases that are handled and the associated message:
(operating-system
services)
guix system: error: services: invalid field specifier. The format of a
field is `(services value)'
(operating-system
(services))
test.scm:2:2: error: (services): Value missing in field specifier. The
format of a field is `(services value)'.
(operating-system
(services 1 2 3))
test.scm:2:2: error: (services 1 2 3): multiple values in field
specifier. Got 3 values associated with key services. Values are:
1
2
3
(operating-system
())
guix system: error: (): invalid field specifier. The format of a field
is `(field value)'
(operating-system
((services %desktop-services)))
test.scm:2:2: error: ((services %desktop-services)): invalid field
specifier. (services %desktop-services) is not a valid field name.
Of course, we can improve these error messages, and internationalize
them.
WDYT?
--MP_/e6eTRR3_p7yxMS_Ql97axbF
Content-Type: text/x-patch
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
filename=0001-guix-records-Improve-error-reporting.patch
=46rom 4cde5555682ca6a3c78cb274cc308087e51ea0e9 Mon Sep 17 00:00:00 2001
From: Julien Lepiller <julien@HIDDEN>
Date: Wed, 21 Jul 2021 01:30:04 +0200
Subject: [PATCH] guix: records: Improve error reporting.
* guix/records.scm (report-invalid-field-specifier): Handle various
invalidity causes separately.
---
guix/records.scm | 37 ++++++++++++++++++++++++++++++++++---
1 file changed, 34 insertions(+), 3 deletions(-)
diff --git a/guix/records.scm b/guix/records.scm
index 3d54a51956..3c3dd478a5 100644
--- a/guix/records.scm
+++ b/guix/records.scm
@@ -1,6 +1,7 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright =C2=A9 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 =
Ludovic Court=C3=A8s <ludo@HIDDEN>
;;; Copyright =C2=A9 2018 Mark H Weaver <mhw@HIDDEN>
+;;; Copyright =C2=A9 2021 Julien Lepiller <julien@HIDDEN>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -83,10 +84,40 @@ error-reporting purposes."
;; WEIRD may be an identifier, thus lacking source location info,=
and
;; BINDINGS is a list, also lacking source location info. Hopefu=
lly
;; PARENT-FORM provides source location info.
- (apply syntax-violation name "invalid field specifier"
- (if parent-form
+ (syntax-case #'weird ()
+ (() ;the empty list
+ (apply syntax-violation name
+ "invalid field specifier. The format of a field is `(f=
ield value)'"
(list parent-form #'weird)
- (list #'weird)))))))
+ (list #'weird)))
+ (((field ...) _ ...) ;a list whose first element is =
a list
+ (apply syntax-violation name
+ (format #f "invalid field specifier. ~a is not a valid =
field name."
+ (map syntax->datum #'(field ...)))
+ (list parent-form #'weird)
+ (list #'weird)))
+ ((field) ;a list with one element
+ (apply syntax-violation name
+ (format #f "Value missing in field specifier. The forma=
t of \
+a field is `(~a value)'."
+ (syntax->datum #'field))
+ (list parent-form #'weird)
+ (list #'weird)))
+ ((field value ...) ;any other list
+ (apply syntax-violation name
+ (format #f "multiple values in field specifier. Got ~a =
values \
+associated with key ~a. Values are:~%~{~a~%~}"
+ (length #'(value ...)) (syntax->datum #'field)
+ (map syntax->datum #'(value ...)))
+ (list parent-form #'weird)
+ (list #'weird)))
+ (field ;not a list
+ (apply syntax-violation name
+ (format #f "invalid field specifier. The format of a f=
ield \
+is `(~a value)'"
+ (syntax->datum #'field))
+ (list parent-form #'weird)
+ (list #'weird))))))))
=20
(define (report-duplicate-field-specifier name ctor)
"Report the first duplicate identifier among the bindings in CTOR."
--=20
2.32.0
--MP_/e6eTRR3_p7yxMS_Ql97axbF--
Julien Lepiller <julien@HIDDEN>:guix-patches@HIDDEN.
Full text available.guix-patches@HIDDEN:bug#49671; Package guix-patches.
Full text available.
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997 nCipher Corporation Ltd,
1994-97 Ian Jackson.