diff --git a/guix/gexp.scm b/guix/gexp.scm index 71041bcbad..8f9cb70d50 100644 --- a/guix/gexp.scm +++ b/guix/gexp.scm @@ -1455,7 +1455,8 @@ and in the current monad setting (system type, etc.)" (($ (? self-quoting? x)) (return x)) (($ x) - (raise (condition (&gexp-input-error (input x))))) + (raise (condition (&gexp-input-error (input x)) + (&error-location (location (gexp-location exp)))))) (x (return x))))) diff --git a/guix/ui.scm b/guix/ui.scm index f99a632b06..f5c6a1af10 100644 --- a/guix/ui.scm +++ b/guix/ui.scm @@ -808,7 +808,8 @@ evaluating the tests and bodies of CLAUSES." target))) ((gexp-input-error? c) (let ((input (gexp-error-invalid-input c))) - (leave (G_ "~s: invalid G-expression input~%") + (leave (and (error-location? c) (error-location c)) + (G_ "~s: invalid G-expression input~%") (gexp-error-invalid-input c)))) ((profile-not-found-error? c) (leave (G_ "profile '~a' does not exist~%") diff --git a/tests/gexp.scm b/tests/gexp.scm index bba8c141f6..1646d48a42 100644 --- a/tests/gexp.scm +++ b/tests/gexp.scm @@ -33,7 +33,10 @@ #:use-module (gnu packages) #:use-module (gnu packages base) #:use-module (gnu packages bootstrap) - #:use-module ((guix diagnostics) #:select (guix-warning-port)) + #:use-module ((guix diagnostics) #:select (error-location + error-location? + guix-warning-port + source-properties->location)) #:use-module (srfi srfi-1) #:use-module (srfi srfi-34) #:use-module (srfi srfi-64) @@ -1307,6 +1310,18 @@ importing.* \\(guix config\\) from the host" (run-with-store %store (lower-gexp #~(#\+))))) +(let* ((g #~#$*unspecified*) + (loc (current-source-location)) ;keep this alignment! + (g-loc (source-properties->location + `((line . ,(- (assq-ref loc 'line) 1)) + ,@(alist-delete 'line loc))))) + (test-equal "lower-gexp, invalid input location" + g-loc + (guard (c ((and (gexp-input-error? c) (error-location? c)) + (error-location c))) + (run-with-store %store + (lower-gexp g))))) + (test-assertm "gexp->derivation #:references-graphs" (mlet* %store-monad ((one (text-file "one" (random-text)))