Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't print "No global of this name exists in this module." on UndefValError #52280

Merged
merged 1 commit into from
Nov 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion base/docs/basedocs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2347,7 +2347,7 @@ julia> module M end;

julia> M.a # same as `getglobal(M, :a)`
ERROR: UndefVarError: `a` not defined in `M`
Suggestion: check for spelling errors or missing imports. No global of this name exists in this module.
Suggestion: check for spelling errors or missing imports.

julia> setglobal!(M, :a, 1)
1
Expand Down
2 changes: 1 addition & 1 deletion doc/src/manual/control-flow.md
Original file line number Diff line number Diff line change
Expand Up @@ -863,7 +863,7 @@ end
foo
end
ERROR: UndefVarError: `foo` not defined in `Main`
Suggestion: check for spelling errors or missing imports. No global of this name exists in this module.
Suggestion: check for spelling errors or missing imports.
```
Use the [`local` keyword](@ref local-scope) outside the `try` block to make the variable
accessible from anywhere within the outer scope.
Expand Down
2 changes: 1 addition & 1 deletion doc/src/manual/variables-and-scoping.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ julia> module D
b = a # errors as D's global scope is separate from A's
end;
ERROR: UndefVarError: `a` not defined in `D`
Suggestion: check for spelling errors or missing imports. No global of this name exists in this module.
Suggestion: check for spelling errors or missing imports.
```

If a top-level expression contains a variable declaration with keyword `local`,
Expand Down
4 changes: 3 additions & 1 deletion stdlib/REPL/src/REPLCompletions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1409,7 +1409,9 @@ function UndefVarError_hint(io::IO, ex::UndefVarError)
else
owner = ccall(:jl_binding_owner, Ptr{Cvoid}, (Any, Any), scope, var)
if C_NULL == owner
print(io, "\nSuggestion: check for spelling errors or missing imports. No global of this name exists in this module.")
# No global of this name exists in this module.
# This is the common case, so do not print that information.
print(io, "\nSuggestion: check for spelling errors or missing imports.")
owner = bnd
else
owner = unsafe_pointer_to_objref(owner)::Core.Binding
Expand Down