Skip to content

Commit

Permalink
add a few type declarations to REPL (#38001)
Browse files Browse the repository at this point in the history
* add a few type declarations to REPL

* change to repr
  • Loading branch information
KristofferC authored Oct 14, 2020
1 parent 15e1d59 commit 026fca9
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions stdlib/REPL/src/LineEdit.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1380,7 +1380,7 @@ function normalize_keys(keymap::Union{Dict{Char,Any},AnyDict})
return ret
end

function add_nested_key!(keymap::Dict, key, value; override = false)
function add_nested_key!(keymap::Dict, key::Union{String, Char}, value; override = false)
y = iterate(key)
while y !== nothing
c, i = y
Expand Down Expand Up @@ -1559,13 +1559,14 @@ function keymap_merge(target::Dict{Char,Any}, source::Union{Dict{Char,Any},AnyDi
end
# then redirected entries
for key in setdiff(keys(source), keys(direct_keys))
key::Union{String, Char}
# We first resolve redirects in the source
value = source[key]
visited = Vector{Any}()
while isa(value, Union{Char,String})
value = normalize_key(value)
if value in visited
error("Eager redirection cycle detected for key " * escape_string(key))
throw_eager_redirection_cycle(key)
end
push!(visited,value)
if !haskey(source,value)
Expand All @@ -1577,14 +1578,19 @@ function keymap_merge(target::Dict{Char,Any}, source::Union{Dict{Char,Any},AnyDi
if isa(value, Union{Char,String})
value = getEntry(ret, value)
if value === nothing
error("Could not find redirected value " * escape_string(source[key]))
throw_could_not_find_redirected_value(key)
end
end
add_nested_key!(ret, key, value; override = true)
end
return ret
end

throw_eager_redirection_cycle(key::Union{Char, String}) =
error("Eager redirection cycle detected for key ", repr(key))
throw_could_not_find_redirected_value(key::Union{Char, String}) =
error("Could not find redirected value ", repl(key))

function keymap_unify(keymaps)
ret = Dict{Char,Any}()
for keymap in keymaps
Expand Down

0 comments on commit 026fca9

Please sign in to comment.