Skip to content

Commit 5dfaef7

Browse files
authored
Limit REPL suggestions to modules from which name is exported/public (#52418)
Close #52387 by implementing the suggestion in #52387 (comment). After this, in a fresh session ```julia julia> Diagonal ERROR: UndefVarError: `Diagonal` not defined in `Main` Suggestion: check for spelling errors or missing imports. Hint: a global variable of this name also exists in LinearAlgebra. ```
1 parent 80ba457 commit 5dfaef7

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

stdlib/REPL/src/REPLCompletions.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1429,7 +1429,7 @@ function UndefVarError_hint(io::IO, ex::UndefVarError)
14291429
else
14301430
scope = undef
14311431
end
1432-
warnfor(m, var) = Base.isbindingresolved(m, var) && isdefined(m, var) && (print(io, "\nHint: a global variable of this name also exists in $m."); true)
1432+
warnfor(m, var) = Base.isbindingresolved(m, var) && (Base.isexported(m, var) || Base.ispublic(m, var)) && (print(io, "\nHint: a global variable of this name also exists in $m."); true)
14331433
if scope !== Base && !warnfor(Base, var)
14341434
warned = false
14351435
for m in Base.loaded_modules_order

0 commit comments

Comments
 (0)