Skip to content

Commit 8b264ab

Browse files
authored
Fix copy of a complicated SizedArray (#1037)
1 parent bd7644f commit 8b264ab

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/abstractarray.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ Base.rdims(out::Tuple{Any}, inds::Tuple{SOneTo, Vararg{SOneTo}}) = (SOneTo(Base.
212212
@inline vec(a::StaticArray) = reshape(a, Size(prod(Size(typeof(a)))))
213213

214214
@inline copy(a::StaticArray) = typeof(a)(Tuple(a))
215-
@inline copy(a::SizedArray) = typeof(a)(copy(a.data))
215+
@inline copy(a::SizedArray{S,T}) where {S,T} = SizedArray{S,T}(copy(a.data))
216216

217217
@inline reverse(v::StaticArray) = typeof(v)(_reverse(v))
218218

test/SizedArray.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,9 @@
125125
sa2 = SizedArray{Tuple{2, 2}, Int}([1, 2, 3, 4])
126126
@test (@inferred vec(sa2)) isa SizedVector{4, Int}
127127
@test vec(sa2).data === vec(sa2.data)
128+
129+
M = @MMatrix [1 2; 3 4]
130+
@test copy(vec(M)) isa SizedVector{4, Int}
128131
end
129132

130133
@testset "aliasing" begin

0 commit comments

Comments
 (0)