Skip to content

Commit

Permalink
bugfix in collect(A) for zero-dimensional array
Browse files Browse the repository at this point in the history
Ref #24187
(cherry picked from commit c59b8b1)
  • Loading branch information
stevengj authored and ararslan committed Nov 21, 2017
1 parent 5a3cbdc commit f2841b5
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 @@ -445,7 +445,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 @@ -841,3 +841,8 @@ end
@testset "checkbounds_indices method ambiguities #20989" begin
@test Base.checkbounds_indices(Bool, (1:1,), ([CartesianIndex(1)],))
end

@testset "zero-dimensional copy" begin
Z = Array{Int}(); Z[] = 17
@test Z == collect(Z) == copy(Z)
end

0 comments on commit f2841b5

Please sign in to comment.