diff --git a/base/array.jl b/base/array.jl index 3b7096fdd254b..c4abdf899b377 100644 --- a/base/array.jl +++ b/base/array.jl @@ -620,7 +620,7 @@ function _collect(cont, itr, ::HasEltype, isz::SizeUnknown) return a end -_collect_indices(::Tuple{}, A) = copy!(Vector{eltype(A)}(), A) +_collect_indices(::Tuple{}, A) = copy!(Array{eltype(A)}(), A) _collect_indices(indsA::Tuple{Vararg{OneTo}}, A) = copy!(Array{eltype(A)}(length.(indsA)), A) function _collect_indices(indsA, A) diff --git a/test/abstractarray.jl b/test/abstractarray.jl index a1d698d2ac933..6e852a90c5b22 100644 --- a/test/abstractarray.jl +++ b/test/abstractarray.jl @@ -872,3 +872,8 @@ end copy!(Array{T,n}(size(a)), a) @test isa(similar(Dict(:a=>1, :b=>2.0), Pair{Union{},Union{}}), Dict{Union{}, Union{}}) end + +@testset "zero-dimensional copy" begin + Z = Array{Int}(); Z[] = 17 + @test Z == collect(Z) == copy(Z) +end