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

REPL shows error when trying to tab-complete after undefined macro name like @undefined.<tab> #42938

Closed
nickrobinson251 opened this issue Nov 4, 2021 · 2 comments

Comments

@nickrobinson251
Copy link
Contributor

nickrobinson251 commented Nov 4, 2021

Tab-completing a name prefixed with @, like @undefined.<tab> shows an error, when i think ideally it would just do nothing. I ran into this when trying to type @Meta.dump and save myself those 4 extra keystrokes.

Here's a longer story, with example (using Julia v1.6.2):

In the REPL, you can tab-complete to get a list of accessible name e.g.

julia> Meta. # <tab> 
@dump                    is_meta_expr_head         parse
@lower                   isbinaryoperator          parseall
ParseError               isexpr                    parseatom
_instantiate_type_in_env isidentifier              partially_inline!
_parse_string            isoperator                quot
_partially_inline!       ispostfixoperator         replace_sourceloc!
eval                     isunaryoperator           sexpr_indent_width
include                  lower                     show_sexpr
julia> Meta.

And if you try to tab-complete after an undefined name, then nothing happens (well, the little julia> prompt will flash, which is cute and helpful, but there'l be no output)

julia> Nonexistant. # <tab> ...nothing happens

You can (unfortunately, in my view) spell macros like Meta.@dump as @Meta.dump

julia> Meta.@dump 1 + 2
Expr
  head: Symbol call
  args: Array{Any}((3,))
    1: Symbol +
    2: Int64 1
    3: Int64 2

julia> @Meta.dump 1 + 2
Expr
  head: Symbol call
  args: Array{Any}((3,))
    1: Symbol +
    2: Int64 1
    3: Int64 2

But if you combine these two things and try to tab-complete @Meta.<tab>, then a big ugly error message is shown:

julia> @Meta.┌ Error: Error in the keymap
│   exception =
│    LoadError: UndefVarError: @Meta not defined
│    Stacktrace:
│      [1] top-level scope
│        @ :0
│      [2] lower
│        @ ./meta.jl:165 [inlined]
│      [3] get_type(sym::Expr, fn::Module)
│        @ REPL.REPLCompletions /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.6/REPL/src/REPLCompletions.jl:459
│      [4] complete_symbol(sym::String, ffunc::REPL.REPLCompletions.var"#34#37", context_module::Module)
│        @ REPL.REPLCompletions /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.6/REPL/src/REPLCompletions.jl:153
│      [5] completions(string::String, pos::Int64, context_module::Module)
│        @ REPL.REPLCompletions /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.6/REPL/src/REPLCompletions.jl:774
│      [6] completions
│        @ /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.6/REPL/src/REPLCompletions.jl:638 [inlined]
│      [7] complete_line(c::REPL.REPLCompletionProvider, s::REPL.LineEdit.PromptState)
│        @ REPL /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.6/REPL/src/REPL.jl:439
│      [8] complete_line(s::REPL.LineEdit.PromptState, repeats::Int64)
│        @ REPL.LineEdit /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.6/REPL/src/LineEdit.jl:348
│      [9] complete_line(s::REPL.LineEdit.MIState)
│        @ REPL.LineEdit /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.6/REPL/src/LineEdit.jl:339
│     [10] edit_tab(s::REPL.LineEdit.MIState, jump_spaces::Bool, delete_trailing::Bool) (repeats 2 times)
│        @ REPL.LineEdit /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.6/REPL/src/LineEdit.jl:2118
│     [11] (::REPL.LineEdit.var"#109#162")(::REPL.LineEdit.MIState, ::Any, ::Vararg{Any, N} where N)
│        @ REPL.LineEdit /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.6/REPL/src/LineEdit.jl:2159
│     [12] #invokelatest#2
│        @ ./essentials.jl:708 [inlined]
│     [13] invokelatest
│        @ ./essentials.jl:706 [inlined]
│     [14] (::REPL.LineEdit.var"#22#23"{REPL.LineEdit.var"#109#162", String})(s::Any, p::Any)
│        @ REPL.LineEdit /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.6/REPL/src/LineEdit.jl:1414
│     [15] prompt!(term::REPL.Terminals.TextTerminal, prompt::REPL.LineEdit.ModalInterface, s::REPL.LineEdit.MIState)
│        @ REPL.LineEdit /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.6/REPL/src/LineEdit.jl:2534
│     [16] run_interface(terminal::REPL.Terminals.TextTerminal, m::REPL.LineEdit.ModalInterface, s::REPL.LineEdit.MIState)
│        @ REPL.LineEdit /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.6/REPL/src/LineEdit.jl:2436
│     [17] run_frontend(repl::REPL.LineEditREPL, backend::REPL.REPLBackendRef)
│        @ REPL /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.6/REPL/src/REPL.jl:1126
│     [18] (::REPL.var"#44#49"{REPL.LineEditREPL, REPL.REPLBackendRef})()
│        @ REPL ./task.jl:411in expression starting at none:1
└ @ REPL.LineEdit /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.6/REPL/src/LineEdit.jl:2536
julia>
julia>

(as this shows, even in the case where these is a valid name available e.g. @Meta.dump)

I think the appropriate behaviour here would be either (i) do nothing (treat @Meta.<tab> or @undefined.<tab> same as Nonexistant.<tab>), or possibly (ii) show the macro names that are valid e.g. @Meta.<tab> would show

julia> @Meta. # <tab>
dump        lower

But really i'd be happy with the first option (i) do nothing.

@nickrobinson251 nickrobinson251 changed the title REPL shows error when trying to tab-complete after macro name @undefined.<tab> REPL shows error when trying to tab-complete after undefined macro name like @undefined.<tab> Nov 4, 2021
@simeonschaub
Copy link
Member

Duplicate of #27184 which was fixed by #40621. Should be backported to 1.6 though.

@nickrobinson251
Copy link
Contributor Author

that's the best!

i guess i should have checked using Nightly 😊

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants