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

Only warn in helpmode on successful nonpublic access #51346

Merged
merged 1 commit into from
Oct 24, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion stdlib/REPL/src/docview.jl
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ struct Logged{F}
collection::Set{Pair{Module,Symbol}}
end
function (la::Logged)(m::Module, s::Symbol)
m !== la.mod && !Base.ispublic(m, s) && push!(la.collection, m => s)
m !== la.mod && Base.isdefined(m, s) && !Base.ispublic(m, s) && push!(la.collection, m => s)
Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not quite sure what the intent is with this code, but checking whether a value is defined seems like a code smell when everything else here is checking for properties of the binding.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want to log any instances of "this global access will succeed but is not public". If isdefined is false, then we'll get an error (or an explicit note that the access is not defined) and there is no need for a warning. I think that Base.isdefined(m, s) && !Base.ispublic(m, s) is equivalent to the (not defined) Base.isprivate(m, s).

la.f(m, s)
end
(la::Logged)(args...) = la.f(args...)
Expand Down
3 changes: 3 additions & 0 deletions stdlib/REPL/test/docview.jl
Original file line number Diff line number Diff line change
Expand Up @@ -132,3 +132,6 @@ module InternalWarningsTests
@test docstring("A.B3") == "No docstring or readme file found for public module `$(@__MODULE__).A.B3`.\n\nModule does not have any public names.\n"
end
end

# Issue #51344, don't print "internal binding" warning for non-existent bindings.
@test string(eval(REPL.helpmode("Base.no_such_symbol"))) == "No documentation found.\n\nBinding `Base.no_such_symbol` does not exist.\n"