-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Typing ?(
in REPL help mode causes exception
#52551
Comments
I believe the problem is that the repl tab completion thinking it is defined in |
The explicit stacktrace is:
|
I don‘t think this is rooted from the inference engine for REPL completion. |
The reason I thought it was is because the stack trace suggests
|
This is indeed independent from the inference engine. Actually it's an issue that dates back to #38791, and it only surfaces now because of #51345. To make it visible on previous versions of julia, execute: julia> module Foo
export bar
bar(x) = nothing
end;
julia> import .Foo
julia> ?(┌ Error: Error in the keymap
│ exception =
│ UndefVarError: bar not defined
│ Stacktrace:
│ [1] complete_any_methods(ex_org::Expr, callee_module::Module, context_module::Module, moreargs::Bool, shift::Bool)
│ @ REPL.REPLCompletions /LionelSSDext4/liozou/julia-1.8.5/share/julia/stdlib/v1.8/REPL/src/REPLCompletions.jl:564
│ [2] completions(string::String, pos::Int64, context_module::Module, shift::Bool)
│ @ REPL.REPLCompletions /LionelSSDext4/liozou/julia-1.8.5/share/julia/stdlib/v1.8/REPL/src/REPLCompletions.jl:787
│ [3] complete_line(c::REPL.REPLCompletionProvider, s::REPL.LineEdit.PromptState)
│ @ REPL /LionelSSDext4/liozou/julia-1.8.5/share/julia/stdlib/v1.8/REPL/src/REPL.jl:497
│ [4] complete_line(s::REPL.LineEdit.PromptState, repeats::Int64)
│ @ REPL.LineEdit /LionelSSDext4/liozou/julia-1.8.5/share/julia/stdlib/v1.8/REPL/src/LineEdit.jl:353
│ [5] complete_line(s::REPL.LineEdit.MIState)
│ @ REPL.LineEdit /LionelSSDext4/liozou/julia-1.8.5/share/julia/stdlib/v1.8/REPL/src/LineEdit.jl:344
│ [6] edit_tab(s::REPL.LineEdit.MIState, jump_spaces::Bool, delete_trailing::Bool) (repeats 2 times)
│ @ REPL.LineEdit /LionelSSDext4/liozou/julia-1.8.5/share/julia/stdlib/v1.8/REPL/src/LineEdit.jl:2180
│ [7] (::REPL.LineEdit.var"#112#166")(::REPL.LineEdit.MIState, ::Any, ::Vararg{Any})
│ @ REPL.LineEdit /LionelSSDext4/liozou/julia-1.8.5/share/julia/stdlib/v1.8/REPL/src/LineEdit.jl:2226
│ [8] #invokelatest#2
│ @ ./essentials.jl:729 [inlined]
│ [9] invokelatest
│ @ ./essentials.jl:726 [inlined]
│ [10] (::REPL.LineEdit.var"#25#26"{REPL.LineEdit.var"#112#166", String})(s::Any, p::Any)
│ @ REPL.LineEdit /LionelSSDext4/liozou/julia-1.8.5/share/julia/stdlib/v1.8/REPL/src/LineEdit.jl:1472
│ [11] prompt!(term::REPL.Terminals.TextTerminal, prompt::REPL.LineEdit.ModalInterface, s::REPL.LineEdit.MIState)
│ @ REPL.LineEdit /LionelSSDext4/liozou/julia-1.8.5/share/julia/stdlib/v1.8/REPL/src/LineEdit.jl:2603
│ [12] run_interface(terminal::REPL.Terminals.TextTerminal, m::REPL.LineEdit.ModalInterface, s::REPL.LineEdit.MIState)
│ @ REPL.LineEdit /LionelSSDext4/liozou/julia-1.8.5/share/julia/stdlib/v1.8/REPL/src/LineEdit.jl:2505
│ [13] run_frontend(repl::REPL.LineEditREPL, backend::REPL.REPLBackendRef)
│ @ REPL /LionelSSDext4/liozou/julia-1.8.5/share/julia/stdlib/v1.8/REPL/src/REPL.jl:1248
│ [14] (::REPL.var"#49#54"{REPL.LineEditREPL, REPL.REPLBackendRef})()
│ @ REPL ./task.jl:484
└ @ REPL.LineEdit /cache/build/default-amdci4-2/julialang/julia-release-1-dot-8/usr/share/julia/stdlib/v1.8/REPL/src/LineEdit.jl:2605 |
Fix #52551. This PR ensures that a `SomeModule.?(...#TAB` completion can only suggests method `foo` such that `SomeModule.foo` exists (by checking `isdefined(SomeModule, :foo)`). This is equivalent, I believe, to the initial implementation of #38791, less the bug. Now that we have #51345, we may want to relax the above condition somewhat to include public names present in modules loaded into `SomeModule`, so that, for instance, a direct completion of `?(` would include `@assume_effects`. This could be good for method exploration because even though typing `@assume_effects` with no qualification in `Main` will error, the error now includes the helpful message ``` Hint: a global variable of this name also exists in Base. ``` But that can wait for a later PR anyway, this one is just the bugfix. The bug mentioned at #52551 (comment) dates from the initial #38791 so this could be backported as far back as v1.8. --------- Co-authored-by: Shuhei Kadowaki <[email protected]>
Fix #52551. This PR ensures that a `SomeModule.?(...#TAB` completion can only suggests method `foo` such that `SomeModule.foo` exists (by checking `isdefined(SomeModule, :foo)`). This is equivalent, I believe, to the initial implementation of #38791, less the bug. Now that we have #51345, we may want to relax the above condition somewhat to include public names present in modules loaded into `SomeModule`, so that, for instance, a direct completion of `?(` would include `@assume_effects`. This could be good for method exploration because even though typing `@assume_effects` with no qualification in `Main` will error, the error now includes the helpful message ``` Hint: a global variable of this name also exists in Base. ``` But that can wait for a later PR anyway, this one is just the bugfix. The bug mentioned at #52551 (comment) dates from the initial #38791 so this could be backported as far back as v1.8. --------- Co-authored-by: Shuhei Kadowaki <[email protected]> (cherry picked from commit a987f56)
if I type
?(
when in the REPL help mode (i.e., after an initial?
), I get the following error messageThe text was updated successfully, but these errors were encountered: