Skip to content

Commit

Permalink
bugfix in collect(A) for zero-dimensional array
Browse files Browse the repository at this point in the history
  • Loading branch information
stevengj committed Oct 27, 2017
1 parent c4558e3 commit c59b8b1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion base/array.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 5 additions & 0 deletions test/abstractarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit c59b8b1

Please sign in to comment.