Skip to content

Commit 283a0aa

Browse files
LilithHafnerNHDaly
authored andcommitted
Don't give public but unexported symbols as repl completions in an unqualified context (#51345)
1 parent ad60899 commit 283a0aa

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

stdlib/REPL/src/REPLCompletions.jl

+1
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ end
136136

137137
function filtered_mod_names(ffunc::Function, mod::Module, name::AbstractString, all::Bool = false, imported::Bool = false)
138138
ssyms = names(mod, all = all, imported = imported)
139+
all || filter!(Base.Fix1(Base.isexported, mod), ssyms)
139140
filter!(ffunc, ssyms)
140141
macros = filter(x -> startswith(String(x), "@" * name), ssyms)
141142
syms = String[sprint((io,s)->Base.show_sym(io, s; allow_macroname=true), s) for s in ssyms if completes_global(String(s), name)]

stdlib/REPL/test/replcompletions.jl

+14
Original file line numberDiff line numberDiff line change
@@ -1896,3 +1896,17 @@ let s = "Issue49892(fal"
18961896
@test n in c
18971897
end
18981898
end
1899+
1900+
@testset "public but non-exported symbols only complete qualified (#51331)" begin
1901+
c, r, res = test_complete("ispub")
1902+
@test res
1903+
@test "ispublic" c
1904+
1905+
c, r, res = test_complete("Base.ispub")
1906+
@test res
1907+
@test "ispublic" c
1908+
1909+
@test Base.ispublic(Base, :ispublic)
1910+
# If this last test starts failing, that's okay, just pick a new example symbol:
1911+
@test !Base.isexported(Base, :ispublic)
1912+
end

0 commit comments

Comments
 (0)