Skip to content

Commit d6bdf50

Browse files
kshyattKristofferC
authored andcommitted
Fix bad c-tor for WeakKeyDict. Fix #35782 (#35783)
(cherry picked from commit ba91a98)
1 parent 0c388fc commit d6bdf50

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

base/weakkeydict.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ function WeakKeyDict(kv)
6969
end
7070
end
7171

72+
sizehint!(d::WeakKeyDict, newsz) = sizehint!(d.ht, newsz)
7273
empty(d::WeakKeyDict, ::Type{K}, ::Type{V}) where {K, V} = WeakKeyDict{K, V}()
7374

7475
islocked(wkh::WeakKeyDict) = islocked(wkh.lock)

test/dict.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -841,6 +841,7 @@ Dict(1 => rand(2,3), 'c' => "asdf") # just make sure this does not trigger a dep
841841
@test isa(WeakKeyDict(A=>2, B=>3, C=>4), WeakKeyDict{Array{Int,1},Int})
842842
@test WeakKeyDict(a=>i+1 for (i,a) in enumerate([A,B,C]) ) == wkd
843843
@test WeakKeyDict([(A,2), (B,3), (C,4)]) == wkd
844+
@test WeakKeyDict{typeof(A), Int64}(Pair(A,2), Pair(B,3), Pair(C,4)) == wkd
844845
@test WeakKeyDict(Pair(A,2), Pair(B,3), Pair(C,4)) == wkd
845846
@test isa(WeakKeyDict(Pair(A,2), Pair(B,3.0), Pair(C,4)), WeakKeyDict{Array{Int,1},Any})
846847
@test isa(WeakKeyDict(Pair(convert(Vector{Number}, A),2), Pair(B,3), Pair(C,4)), WeakKeyDict{Any,Int})

0 commit comments

Comments
 (0)