guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

05/06: ui: Only suggest modules that export the unbound variable identif


From: guix-commits
Subject: 05/06: ui: Only suggest modules that export the unbound variable identifier.
Date: Thu, 15 Oct 2020 12:51:34 -0400 (EDT)

civodul pushed a commit to branch master
in repository guix.

commit 5ef1508942ee083ed22b844f5291e59320016b79
Author: Ludovic Courtès <ludo@gnu.org>
AuthorDate: Thu Oct 15 16:41:14 2020 +0200

    ui: Only suggest modules that export the unbound variable identifier.
    
    Fixes <https://bugs.gnu.org/43498>.
    Reported by Tobias Geerinckx-Rice <me@tobias.gr>.
    
    * guix/ui.scm (known-variable-definition): Check for variables in the
    public interface of HEAD, not in HEAD itself.
    * tests/guix-build.sh: Add test.
---
 guix/ui.scm         |  3 ++-
 tests/guix-build.sh | 27 +++++++++++++++++++++++++++
 2 files changed, 29 insertions(+), 1 deletion(-)

diff --git a/guix/ui.scm b/guix/ui.scm
index 8213e8e..8d7bc23 100644
--- a/guix/ui.scm
+++ b/guix/ui.scm
@@ -297,7 +297,8 @@ VARIABLE and return it, or #f if none was found."
                                   (hash-map->list (lambda (name module)
                                                     module)
                                                   (module-submodules head)))))
-             (match (module-local-variable head variable)
+             (match (and=> (module-public-interface head)
+                           (cut module-local-variable <> variable))
                (#f (loop next suggestions visited))
                (_
                 (match (module-name head)
diff --git a/tests/guix-build.sh b/tests/guix-build.sh
index 6dbb532..4a58ea1 100644
--- a/tests/guix-build.sh
+++ b/tests/guix-build.sh
@@ -198,6 +198,33 @@ grep "forget.*(guix build-system gnu)" "$module_dir/err" # 
hint
 
 rm -f "$module_dir"/*
 
+# Unbound variable: don't suggest modules that do not export the variable.
+cat > "$module_dir/aa-private.scm" <<EOF
+(define-module (aa-private))
+(define make-thing #f)
+(set! make-thing make-thing)   ;don't inline
+EOF
+
+cat > "$module_dir/bb-public.scm" <<EOF
+(define-module (bb-public) #:export (make-thing))
+(define make-thing identity)
+EOF
+
+cat > "$module_dir/cc-user.scm" <<EOF
+;; Make those module available in the global name space.
+(load-from-path "aa-private.scm")
+(load-from-path "bb-public.scm")
+
+(define-module (cc-user))
+(make-thing 42)
+EOF
+! guix build -f "$module_dir/cc-user.scm" -n 2> "$module_dir/err"
+cat "$module_dir/err"
+grep "make-thing.*unbound" "$module_dir/err"            # actual error
+grep "forget.*(bb-public)" "$module_dir/err"            # hint
+
+rm -f "$module_dir"/*
+
 # Wrong 'define-module' clause reported by 'warn-about-load-error'.
 cat > "$module_dir/foo.scm" <<EOF
 (define-module (something foo)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]