diff mbox series

[bug#54236] Two fixes for 'gexp->approximate-sexp', addressing some linter problems.

Message ID ffb6e750df4a97e19abcf2d3bd80df291266b969.camel@telenet.be
State Accepted
Headers show
Series [bug#54236] Two fixes for 'gexp->approximate-sexp', addressing some linter problems. | expand

Checks

Context Check Description
cbaines/applying patch fail View Laminar job
cbaines/issue success View issue

Commit Message

M March 3, 2022, 2:21 p.m. UTC
Hi guix,

Try "guix lint -c wrapper-inputs libaio".  You'll see a false positive.
The first patch fixes it.  This fix exposes another issue, causing
"guix lint -c wrapper-inputs hostapd" to backtrace.  The second patches
fixes that.

Greetings,
Maxime.

Comments

Ludovic Courtès March 11, 2022, 10:22 p.m. UTC | #1
Hello,

Both patches LGTM, except for…

Maxime Devos <maximedevos@telenet.be> skribis:

> From 2aae3582fec4ba6ca719eacaa61f17589b09755e Mon Sep 17 00:00:00 2001
> From: Maxime Devos <maximedevos@telenet.be>
> Date: Thu, 3 Mar 2022 13:57:03 +0000
> Subject: [PATCH 1/2] gexp: Correctly handle unquoting S-exp objects.
>
> TODO before committing: fix the link to issues.guix.gnu.org in tests/gexp.scm.

… this TODO.  :-)

Is there an actual issue to refer to, or just this one?

Thanks,
Ludo’.
M March 11, 2022, 10:34 p.m. UTC | #2
Ludovic Courtès schreef op vr 11-03-2022 om 23:22 [+0100]:
> Is there an actual issue to refer to, or just this one?

Yes, it's a ‘self-referrent patch’.  This patch
<https://issues.guix.gnu.org/54236> refers to the corresponding issue
<https://issues.guix.gnu.org/54236>.

Greetings,
Maxime.
Ludovic Courtès March 13, 2022, 10:20 p.m. UTC | #3
Maxime Devos <maximedevos@telenet.be> skribis:

> Ludovic Courtès schreef op vr 11-03-2022 om 23:22 [+0100]:
>> Is there an actual issue to refer to, or just this one?
>
> Yes, it's a ‘self-referrent patch’.  This patch
> <https://issues.guix.gnu.org/54236> refers to the corresponding issue
> <https://issues.guix.gnu.org/54236>.

Ah ah, got it.  :-)

Applied, thanks!

Ludo’.
diff mbox series

Patch

From a34cb77369a6108e65be20ef36ab35bdf398daf1 Mon Sep 17 00:00:00 2001
From: Maxime Devos <maximedevos@telenet.be>
Date: Thu, 3 Mar 2022 14:14:22 +0000
Subject: [PATCH 2/2] gexp: Correctly handle #$output in
 'gexp->approximate-sexp'.

This addresses the following backtrace from
"guix lint -c wrapper-inputs hostapd":

Backtrace:ostapd@2.10 [wrapper-inputs]...
[...]
    174:9  3 (gexp->approximate-sexp #<gexp (modify-phases %standard?>)
In srfi/srfi-1.scm:
   586:17  2 (map1 (#<gexp-output out> #<gexp-input "pkg-config":o?>))
In guix/gexp.scm:
   175:16  1 (_ _)
In ice-9/boot-9.scm:
  1685:16  0 (raise-exception _ #:continuable? _)

ice-9/boot-9.scm:1685:16: In procedure raise-exception:
Throw to key `match-error' with args `("match" "no matching pattern" #<gexp-output out>)'.

* guix/gexp.scm (gexp->approximate-sexp): Handle the case where 'reference' is
  a <gexp-output>,, by returning (*approximate*).
* tests/gexp.scm ("gexp->approximate-sexp, outputs"): Test it.
---
 guix/gexp.scm  | 3 ++-
 tests/gexp.scm | 5 +++++
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/guix/gexp.scm b/guix/gexp.scm
index c358662799..22a6c6ab71 100644
--- a/guix/gexp.scm
+++ b/guix/gexp.scm
@@ -181,7 +181,8 @@  As a result, the S-expression will be approximate if GEXP has references."
                          (#true
                           ;; Simply returning 'thing' won't work in some
                           ;; situations; see 'write-gexp' below.
-                          '(*approximate*))))))
+                          '(*approximate*))))
+                  (($ <gexp-output>) '(*approximate*))))
               (gexp-references gexp))))
 
 (define (write-gexp gexp port)
diff --git a/tests/gexp.scm b/tests/gexp.scm
index 5ac8a1c8ab..5d98f836a7 100644
--- a/tests/gexp.scm
+++ b/tests/gexp.scm
@@ -147,6 +147,11 @@ 
          (null? (gexp-inputs exp))
          (gexp->sexp* exp))))
 
+(test-equal "gexp->approximate-sexp, outputs"
+  '(list 'out:foo (*approximate*) 'out:bar (*approximate*))
+  (gexp->approximate-sexp
+   #~(list 'out:foo #$output:foo 'out:bar #$output:bar)))
+
 (test-equal "unquote"
   '(display `(foo ,(+ 2 3)))
   (let ((exp (gexp (display `(foo ,(+ 2 3))))))
-- 
2.30.2