diff --git a/guix/ui.scm b/guix/ui.scm index 8213e8ebab..8d7bc238bc 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 6dbb53206e..4a58ea1476 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" < "$module_dir/bb-public.scm" < "$module_dir/cc-user.scm" < "$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" <