Skip to content

Commit

Permalink
Type-assert the value type in getindex(::AbstractDict, key) (JuliaLan…
Browse files Browse the repository at this point in the history
  • Loading branch information
fredrikekre authored and pull[bot] committed Jun 30, 2023
1 parent d688d91 commit e081db6
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions base/abstractdict.jl
Original file line number Diff line number Diff line change
Expand Up @@ -536,12 +536,12 @@ function hash(a::AbstractDict, h::UInt)
hash(hv, h)
end

function getindex(t::AbstractDict, key)
function getindex(t::AbstractDict{<:Any,V}, key) where V
v = get(t, key, secret_table_token)
if v === secret_table_token
throw(KeyError(key))
end
return v
return v::V
end

# t[k1,k2,ks...] is syntactic sugar for t[(k1,k2,ks...)]. (Note
Expand Down

0 comments on commit e081db6

Please sign in to comment.