Skip to content

Commit 9884e44

Browse files
authored
Don't print "No global of this name exists in this module." on UndefValError (#52280)
1 parent 38438d7 commit 9884e44

File tree

4 files changed

+6
-4
lines changed

4 files changed

+6
-4
lines changed

base/docs/basedocs.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2347,7 +2347,7 @@ julia> module M end;
23472347
23482348
julia> M.a # same as `getglobal(M, :a)`
23492349
ERROR: UndefVarError: `a` not defined in `M`
2350-
Suggestion: check for spelling errors or missing imports. No global of this name exists in this module.
2350+
Suggestion: check for spelling errors or missing imports.
23512351
23522352
julia> setglobal!(M, :a, 1)
23532353
1

doc/src/manual/control-flow.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -863,7 +863,7 @@ end
863863
foo
864864
end
865865
ERROR: UndefVarError: `foo` not defined in `Main`
866-
Suggestion: check for spelling errors or missing imports. No global of this name exists in this module.
866+
Suggestion: check for spelling errors or missing imports.
867867
```
868868
Use the [`local` keyword](@ref local-scope) outside the `try` block to make the variable
869869
accessible from anywhere within the outer scope.

doc/src/manual/variables-and-scoping.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ julia> module D
9191
b = a # errors as D's global scope is separate from A's
9292
end;
9393
ERROR: UndefVarError: `a` not defined in `D`
94-
Suggestion: check for spelling errors or missing imports. No global of this name exists in this module.
94+
Suggestion: check for spelling errors or missing imports.
9595
```
9696

9797
If a top-level expression contains a variable declaration with keyword `local`,

stdlib/REPL/src/REPLCompletions.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1409,7 +1409,9 @@ function UndefVarError_hint(io::IO, ex::UndefVarError)
14091409
else
14101410
owner = ccall(:jl_binding_owner, Ptr{Cvoid}, (Any, Any), scope, var)
14111411
if C_NULL == owner
1412-
print(io, "\nSuggestion: check for spelling errors or missing imports. No global of this name exists in this module.")
1412+
# No global of this name exists in this module.
1413+
# This is the common case, so do not print that information.
1414+
print(io, "\nSuggestion: check for spelling errors or missing imports.")
14131415
owner = bnd
14141416
else
14151417
owner = unsafe_pointer_to_objref(owner)::Core.Binding

0 commit comments

Comments
 (0)