diff --git a/base/repl/REPLCompletions.jl b/base/repl/REPLCompletions.jl index e680425e94469..516846570ffd6 100644 --- a/base/repl/REPLCompletions.jl +++ b/base/repl/REPLCompletions.jl @@ -71,11 +71,13 @@ function complete_symbol(sym, ffunc) end else # Looking for a member of a type - fields = fieldnames(t) - for field in fields - s = string(field) - if startswith(s, name) - push!(suggestions, s) + if t isa DataType && t != Any + fields = fieldnames(t) + for field in fields + s = string(field) + if startswith(s, name) + push!(suggestions, s) + end end end end diff --git a/test/replcompletions.jl b/test/replcompletions.jl index 1c22d90c4efe1..ba9fcf35fabb8 100644 --- a/test/replcompletions.jl +++ b/test/replcompletions.jl @@ -51,7 +51,8 @@ ex = quote test5(x::Float64) = pass const a=x->x test6()=[a, a] - + test7() = rand() > 0.5 ? 1 : 1.0 + test8() = Any[1][1] kwtest(; x=1, y=2, w...) = pass array = [1, 1] @@ -172,6 +173,11 @@ s = "using Base\nusi" c,r = test_complete(s) @test "using" in c +# issue 23292 +@test_nowarn test_complete("test7().") +c,r = test_complete("test8().") +@test isempty(c) + # inexistent completion inside a string s = "Pkg.add(\"lol" c,r,res = test_complete(s)