Skip to content

Commit

Permalink
Add type assertion in deepcopy_internal for Arrays (JuliaLang#40909)
Browse files Browse the repository at this point in the history
Add type assertion in deepcopy_internal for Arrays
  • Loading branch information
jishnub committed May 25, 2021
1 parent 6f71de4 commit ff85419
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion base/deepcopy.jl
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ end

function deepcopy_internal(x::Array, stackdict::IdDict)
if haskey(stackdict, x)
return stackdict[x]
return stackdict[x]::typeof(x)
end
_deepcopy_array_t(x, eltype(x), stackdict)
end
Expand Down
6 changes: 5 additions & 1 deletion test/copy.jl
Original file line number Diff line number Diff line change
Expand Up @@ -233,4 +233,8 @@ end
@test copyto!(s, view(Int[],Int[])) == [1, 2]
@test copyto!(s, Float64[]) == [1, 2]
@test copyto!(s, String[]) == [1, 2] # No error
end
end

@testset "deepcopy_internal arrays" begin
@test (@inferred Base.deepcopy_internal(zeros(), IdDict())) == zeros()
end

0 comments on commit ff85419

Please sign in to comment.