Skip to content

MethodError in edit_insert keymap fallback on Julia 1.12 (debugmode.jl:129) #420

Description

@mattlie82

Description

After using Debugger on Julia 1.12, any REPL keymap action that Debugger.jl intercepts and then falls through to normal character insertion (e.g. typing )) throws a MethodError instead of inserting the character. This happens consistently and makes the REPL nearly unusable while Debugger is loaded.

Environment

  • Julia: 1.12.7 (aarch64-apple-darwin14, via juliaup)
  • Debugger.jl: latest master / most recent tagged release (bug persists after ] up Debugger)

Steps to reproduce

julia> using Debugger
julia> foo(

Typing the closing ) at the REPL triggers the error below.

Error

┌ Error: Error in the keymap
│   exception =
│    MethodError: no method matching edit_insert(::REPL.LineEdit.PromptState, ::REPL.LineEditREPL, ::String)
│    The function `edit_insert` exists, but no method is defined for this combination of argument types.
│
│    Closest candidates are:
│      edit_insert(::REPL.LineEdit.MIState, ::Any...)
│       @ REPL .../share/julia/stdlib/v1.12/REPL/src/LineEdit.jl:263
│      edit_insert(::REPL.LineEdit.PromptState, ::Union{Char, SubString{String}, String})
│       @ REPL .../share/julia/stdlib/v1.12/REPL/src/LineEdit.jl:960
│      edit_insert(::IOBuffer, ::Union{Char, SubString{String}, String})
│       @ REPL .../share/julia/stdlib/v1.12/REPL/src/LineEdit.jl:1034
│
│    Stacktrace:
│     [1] edit_insert(::REPL.LineEdit.MIState, ::Any, ::Any)
│       @ REPL.LineEdit .../share/julia/stdlib/v1.12/REPL/src/LineEdit.jl:265
│     [2] (::Debugger.var"#110#111"{typeof(REPL.LineEdit.edit_insert), REPL.LineEdit.Prompt})(::REPL.LineEdit.MIState, ::REPL.LineEditREPL, ::Vararg{Any})
│       @ Debugger ~/.julia/packages/Debugger/1HzXT/src/debugmode.jl:129
│     [3] (::REPL.LineEdit.var"#match_input##0#match_input##1"{Debugger.var"#110#111"{typeof(REPL.LineEdit.edit_insert), REPL.LineEdit.Prompt}, String})(s::Any, p::Any)
│       @ REPL.LineEdit .../share/julia/stdlib/v1.12/REPL/src/LineEdit.jl:1810
│     [4] macro expansion
│       @ .../share/julia/stdlib/v1.12/REPL/src/LineEdit.jl:2960 [inlined]
│     [5] macro expansion
│       @ ./lock.jl:376 [inlined]
│     [6] (::REPL.LineEdit.var"#prompt!##2#prompt!##3"{Base.Terminals.TTYTerminal, REPL.LineEdit.ModalInterface, REPL.LineEdit.MIState, REPL.LineEdit.Prompt})()
│       @ REPL.LineEdit .../share/julia/stdlib/v1.12/REPL/src/LineEdit.jl:2949
└ @ REPL.LineEdit .../share/julia/stdlib/v1.12/REPL/src/LineEdit.jl:2962

Root cause

Frame [2] points to debugmode.jl:129, where a closure (Debugger.var"#110#111") wraps REPL.LineEdit.edit_insert as a fallback action for keymap entries that Debugger.jl intercepts but doesn't otherwise handle (e.g. ) at a non-empty prompt). That closure forwards the repl argument along with the character into edit_insert, i.e. effectively calling edit_insert(state, repl, char).

On Julia 1.12, edit_insert only defines 2-argument methods for PromptState/IOBuffer (edit_insert(s, c)) plus a catch-all edit_insert(s::MIState, ::Any...). There's no 3-argument method that accepts (PromptState, LineEditREPL, char), so the fallback call fails with a MethodError whenever the keymap dispatch passes the repl object through (this appears to be new/changed behavior in 1.12's match_input/keymap machinery — see LineEdit.jl:1810).

Suggested fix

The fallback closure in debugmode.jl around line 129 should call edit_insert(state, char) (dropping the extra repl argument) rather than forwarding all positional arguments through.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions