Skip to content

Autocompletion triggers error in invalid AbstractDict #54892

@jakobnissen

Description

@jakobnissen

So, this may or may not be intended behaviour.
I'm writing a package with a new AbstractDict type, which is lazily validated. That means its possible to construct an invalid instance (which may be checked with isvalid). Encountering an invalid value when iterating the dict, or accessing an invalid key will throw an exception.
Problem is, the REPL will access the dictionary while giving autocomplete suggestions (see below)

Is this a problem? Maybe it's fair to assume iterating an AbstractDict never errors.

julia> aux["K┌ Error: Error in the keymap
│   exception =
│    Bad AuxTag
│    Stacktrace:
│      [1] error(s::String)
│        @ Base ./error.jl:44
│      [2] (::XAMAuxData.var"#5#6")(val::XAMAuxData.Errors.Error)
│        @ XAMAuxData ~/code/XAMAuxData.jl/src/XAMAuxData.jl:213
│      [3] iterate
│        @ ./generator.jl:48 [inlined]
│      [4] find_dict_matches(identifier::XAMAuxData.BAM.Auxiliary{MemViews.ImmutableMemView{UInt8}}, partial_key::String)
│        @ REPL.REPLCompletions ~/code/julia/usr/share/julia/stdlib/v1.12/REPL/src/REPLCompletions.jl:1000
│      [5] completions(string::String, pos::Int64, context_module::Module, shift::Bool, hint::Bool)
│        @ REPL.REPLCompletions ~/code/julia/usr/share/julia/stdlib/v1.12/REPL/src/REPLCompletions.jl:1249
│      [6] complete_line(c::REPL.REPLCompletionProvider, s::REPL.LineEdit.PromptState, mod::Module; hint::Bool)
│        @ REPL ~/code/julia/usr/share/julia/stdlib/v1.12/REPL/src/REPL.jl:659
│      [7] check_for_hint(s::REPL.LineEdit.MIState)
│        @ REPL.LineEdit ~/code/julia/usr/share/julia/stdlib/v1.12/REPL/src/LineEdit.jl:384
│      [8] (::REPL.LineEdit.var"#143#199")(s::REPL.LineEdit.MIState, data::Any, c::Union{Char, SubString{String}, String})
│        @ REPL.LineEdit ~/code/julia/usr/share/julia/stdlib/v1.12/REPL/src/LineEdit.jl:2520
│      [9] #invokelatest#2
│        @ ./essentials.jl:1045 [inlined]
│     [10] invokelatest
│        @ ./essentials.jl:1042 [inlined]
│     [11] (::REPL.LineEdit.var"#30#31"{REPL.LineEdit.var"#143#199", String})(s::Any, p::Any)
│        @ REPL.LineEdit ~/code/julia/usr/share/julia/stdlib/v1.12/REPL/src/LineEdit.jl:1704
│     [12] macro expansion
│        @ ~/code/julia/usr/share/julia/stdlib/v1.12/REPL/src/LineEdit.jl:2854 [inlined]
│     [13] macro expansion
│        @ ./lock.jl:273 [inlined]
│     [14] (::REPL.LineEdit.var"#282#284"{REPL.Terminals.TTYTerminal, REPL.LineEdit.ModalInterface, REPL.LineEdit.MIState, ReentrantLock, REPL.LineEdit.Prompt})()
│        @ REPL.LineEdit ~/code/julia/usr/share/julia/stdlib/v1.12/REPL/src/LineEdit.jl:2844
└ @ REPL.LineEdit ~/code/julia/usr/share/julia/stdlib/v1.12/REPL/src/LineEdit.jl:2856

Metadata

Metadata

Assignees

No one assigned

    Labels

    REPLJulia's REPL (Read Eval Print Loop)bugIndicates an unexpected problem or unintended behaviorcollectionsData structures holding multiple items, e.g. setscompletionsTab and autocompletion in the replneeds decisionA decision on this change is needed

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions