diff --git a/base/deepcopy.jl b/base/deepcopy.jl index 01c0d3bbd61e5..45a7755a77ae6 100644 --- a/base/deepcopy.jl +++ b/base/deepcopy.jl @@ -96,7 +96,7 @@ function _deepcopy_array_t(@nospecialize(x), T, stackdict::IdDict) return dest end -function deepcopy_internal(x::Dict, stackdict::IdDict) +function deepcopy_internal(x::Union{Dict,IdDict}, stackdict::IdDict) if haskey(stackdict, x) return stackdict[x]::typeof(x) end diff --git a/test/copy.jl b/test/copy.jl index 80052a1cc6465..fd0128c2a661a 100644 --- a/test/copy.jl +++ b/test/copy.jl @@ -153,4 +153,14 @@ end @test bar2.foo ∈ keys(bar2.fooDict) @test bar2.fooDict[bar2.foo] != nothing end + + let d = IdDict(rand(2) => rand(2) for i = 1:100) + d2 = deepcopy(d) + for k in keys(d2) + @test haskey(d2, k) + end + for k in keys(d) + @test haskey(d, k) + end + end end