Subject: [PATCH v3] gexp: Handle *unspecified* as a gexp input.

From: Maxim Cournoyer <[email-masked]>
Date: Thu, 28 Jul 2022 00:41:44 -0400

Fixes <https://issues.guix.gnu.org/56799>.

* guix/gexp.scm (gexp->sexp)[*unspecified*]: Quote value when encountering it.
---
 guix/gexp.scm  | 2 ++
 tests/gexp.scm | 6 ++++++
 2 files changed, 8 insertions(+)

diff --git a/guix/gexp.scm b/guix/gexp.scm
index ef92223048..fe47a116f6 100644
--- a/guix/gexp.scm
+++ b/guix/gexp.scm
@@ -1380,6 +1380,8 @@ (define* (reference->sexp ref #:optional native?)
                                 #:output output)))
         (($ <gexp-input> (? self-quoting? x))
          (return x))
+        (($ <gexp-input> (? unspecified?))
+         (return '*unspecified*))
         (($ <gexp-input> x)
          (raise (condition (&gexp-input-error (input x)))))
         (x
diff --git a/tests/gexp.scm b/tests/gexp.scm
index 07e940ffdc..cad139fde7 100644
--- a/tests/gexp.scm
+++ b/tests/gexp.scm
@@ -1128,6 +1128,12 @@ (define (matching-input drv output)
     (run-with-store %store
       (lower-gexp #~(foo #$+)))))
 
+(test-equal "lower-gexp, *unspecified* input"
+  '(*unspecified*)
+  (lowered-gexp-sexp
+   (run-with-store %store
+     (lower-gexp #~(#$*unspecified*)))))
+
 (test-equal "lower-gexp, character literal"
   '(#\+)
   (lowered-gexp-sexp
-- 
2.36.1