JuliaLang / julia

The Julia Programming Language
https://julialang.org/
MIT License
45.53k stars 5.46k forks source link

[REPL] Autocompletion of `ModuleName.@macro_name` is broken #55518

Open giordano opened 1 month ago

giordano commented 1 month ago

On 5230d27de9

julia> Base.@time nothi<TAB>

autocompletes nothi to nothing_sentinel:

julia> Base.@time nothing_sentinel
ERROR: UndefVarError: `nothing_sentinel` not defined in `Main`
Suggestion: check for spelling errors or missing imports.
Stacktrace:
 [1] macro expansion
   @ ./timing.jl:579 [inlined]
 [2] top-level scope
   @ ./REPL[17]:1

If I understand it correctly, ModuleName.@macro symbol<TAB> autocompletes symbol inside ModuleName, not Main:

julia> module Issue55518
       macro name(expr) :($(esc(expr))) end
       const not_really_what_I_wanted = something
       end
Main.Issue55518

julia> using .Issue55518

julia> Issue55518.@name not<TAB>

This works correctly in Julia v1.10 and v1.11.0-rc1

giordano commented 2 weeks ago

I just ran again into this by trying to autocomplete in the REPL a Threads.@threads for loop.

giordano commented 1 week ago

We have an upgrade: also autocompletion of keyword arguments is now broken:

julia> module Issue55518
       macro name(expr) :($(esc(expr))) end
       const not_really_what_I_wanted = something
       f(; x) = x
       end
Main.Issue55518

julia> using .Issue55518

julia> Issue55518.f(; x=<TAB>
@name
eval
f
include
not_really_what_I_wanted

Trying to autocomplete the value of the keyword arguments complete only symbols within the module, also those that aren't exported and so you shouldn't even be able to reference them unless you imported them explicitly, which I didn't here.