Skip to content

Commit

Permalink
Limit REPL suggestions to modules from which name is exported/public (#…
Browse files Browse the repository at this point in the history
…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.
```
  • Loading branch information
jishnub authored Dec 8, 2023
1 parent 80ba457 commit 5dfaef7
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion stdlib/REPL/src/REPLCompletions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1429,7 +1429,7 @@ function UndefVarError_hint(io::IO, ex::UndefVarError)
else
scope = undef
end
warnfor(m, var) = Base.isbindingresolved(m, var) && isdefined(m, var) && (print(io, "\nHint: a global variable of this name also exists in $m."); true)
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)
if scope !== Base && !warnfor(Base, var)
warned = false
for m in Base.loaded_modules_order
Expand Down

0 comments on commit 5dfaef7

Please sign in to comment.