julia
a12d0ff6 - make copy correctly handle 0-dimensional SubArray (#39809)

Commit
4 years ago
make copy correctly handle 0-dimensional SubArray (#39809) * make copy correctly handle 0-dimensional SubArray The current definition of `copy` for `SubArray` [here](https://github.com/JuliaLang/julia/blob/master/base/subarray.jl#L70) has the following consequence: ``` julia> x = [1] 1-element Array{Int64,1}: 1 julia> y = @view x[1] 0-dimensional view(::Array{Int64,1}, 1) with eltype Int64: 1 julia> copy(y) 1 ``` which is inconsistent with the contract for `copy` that promises to produce an array when array is copied, e.g.: ``` julia> x = fill(1) 0-dimensional Array{Int64,0}: 1 julia> copy(x) 0-dimensional Array{Int64,0}: 1 ```
Author
Parents
Loading