From 44e383f595f843f0d0194cb605e10511d7300c1a Mon Sep 17 00:00:00 2001 From: "Steven G. Johnson" Date: Wed, 18 Oct 2017 17:23:54 -0400 Subject: [PATCH] bugfix in collect(A) for zero-dimensional array --- base/array.jl | 2 +- test/abstractarray.jl | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/base/array.jl b/base/array.jl index 39693ce6c7be30..f3f54983a6c6fb 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 9c6b0d51e207f7..f5e8e0c486bff8 100644 --- a/test/abstractarray.jl +++ b/test/abstractarray.jl @@ -864,3 +864,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