me
/
guix
Archived
1
0
Fork 0

gexp: Correctly handle unquoting S-exp objects.

This fixes a false-positive in the linter:

  guix lint -c 'wrapper-inputs' libaio

* guix/gexp.scm (gexp->approximate-sexp): Allow the 'thing' in <gexp-input> to
  be a sexp, without approximation, by testing if it is a record.
* tests/gexp.scm ("unquoted sexp (not a gexp!)"): Test it.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
master
Maxime Devos 2022-03-03 13:57:03 +00:00 committed by Ludovic Courtès
parent fce9f13b54
commit 5aec62ee0f
No known key found for this signature in database
GPG Key ID: 090B11993D9AEBB5
2 changed files with 23 additions and 8 deletions

View File

@ -4,7 +4,7 @@
;;; Copyright © 2018 Jan Nieuwenhuizen <janneke@gnu.org>
;;; Copyright © 2019, 2020 Mathieu Othacehe <m.othacehe@gmail.com>
;;; Copyright © 2020 Maxim Cournoyer <maxim.cournoyer@gmail.com>
;;; Copyright © 2021 Maxime Devos <maximedevos@telenet.be>
;;; Copyright © 2021, 2022 Maxime Devos <maximedevos@telenet.be>
;;;
;;; This file is part of GNU Guix.
;;;
@ -174,12 +174,14 @@ As a result, the S-expression will be approximate if GEXP has references."
(map (lambda (reference)
(match reference
(($ <gexp-input> thing output native)
(if (gexp-like? thing)
(gexp->approximate-sexp thing)
;; Simply returning 'thing' won't work in some
;; situations; see 'write-gexp' below.
'(*approximate*)))
(_ '(*approximate*))))
(cond ((gexp-like? thing)
(gexp->approximate-sexp thing))
((not (record? thing)) ; a S-exp
thing)
(#true
;; Simply returning 'thing' won't work in some
;; situations; see 'write-gexp' below.
'(*approximate*))))))
(gexp-references gexp))))
(define (write-gexp gexp port)

View File

@ -1,6 +1,6 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2014-2022 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2021 Maxime Devos <maximedevos@telenet.be>
;;; Copyright © 2021-2022 Maxime Devos <maximedevos@telenet.be>
;;;
;;; This file is part of GNU Guix.
;;;
@ -121,6 +121,19 @@
(let ((inside (file-append coreutils "/bin/hello")))
(gexp->approximate-sexp #~(display '#$inside))))
;; See <https://issues.guix.gnu.org/54236>.
(test-equal "unquoted sexp (not a gexp!)"
'(list #(foo) (foo) () "foo" foo #xf00)
(let ((inside/vector #(foo))
(inside/list '(foo))
(inside/empty '())
(inside/string "foo")
(inside/symbol 'foo)
(inside/number #xf00))
(gexp->approximate-sexp
#~(list #$inside/vector #$inside/list #$inside/empty #$inside/string
#$inside/symbol #$inside/number))))
(test-equal "no refs"
'(display "hello!")
(let ((exp (gexp (display "hello!"))))