julia
d295d4d2 - REPL: Convert char to string before calling `escape_string` (#61143)

Commit
23 days ago
REPL: Convert char to string before calling `escape_string` (#61143) In this function, `key` is allowed to be either `String` or `Char`, but there is no method matching `escape_string(::Char)`. So convert `key` to a string before calling `escape_string`. MWE: ``` import REPL keymap = Dict{Char, Any}() REPL.LineEdit.add_nested_key!(keymap, 'a', "foo") REPL.LineEdit.add_nested_key!(keymap, 'a', "bar") ``` Which throws this error: ``` julia> REPL.LineEdit.add_nested_key!(keymap, 'a', "bar") ERROR: MethodError: no method matching escape_string(::Char) The function `escape_string` exists, but no method is defined for this combination of argument types. Closest candidates are: escape_string(::IO, ::Union{Base.AnnotatedString, SubString{<:Base.AnnotatedString}}, ::Any; keep, ascii, fullhex) @ Base strings/annotated_io.jl:266 escape_string(::IO, ::Union{Base.AnnotatedString, SubString{<:Base.AnnotatedString}}; ...) @ Base strings/annotated_io.jl:266 escape_string(::AbstractString, ::Any; keep, ascii, fullhex) @ Base strings/io.jl:467 ... Stacktrace: [1] add_nested_key!(keymap::Dict{Char, Any}, key::Union{Char, String}, value::Any; override::Bool) @ REPL.LineEdit ~/juliaup.depot/juliaup/julia-1.12.5+0.aarch64.apple.darwin14/Julia-1.12.app/Contents/Resources/julia/share/julia/stdlib/v1.12/REPL/src/LineEdit.jl:1785 [2] add_nested_key!(keymap::Dict{Char, Any}, key::Union{Char, String}, value::Any) @ REPL.LineEdit ~/juliaup.depot/juliaup/julia-1.12.5+0.aarch64.apple.darwin14/Julia-1.12.app/Contents/Resources/julia/share/julia/stdlib/v1.12/REPL/src/LineEdit.jl:1779 [3] top-level scope @ REPL[3]:1 ``` But we want it to throw this instead: ``` ERROR: Conflicting definitions for keyseq a within one keymap ``` --- Detected by JET. (cherry picked from commit ffb7fe3555157ad93b1f5099849f768270539549)
Author
Committer
Parents
Loading