Skip to content

Commit 35b32ac

Browse files
fix: fix broadcasted assignment to VOA of StaticArrays
1 parent 6e0aa08 commit 35b32ac

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/vector_of_array.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,7 @@ end
661661
bc = Broadcast.flatten(bc)
662662
N = narrays(bc)
663663
@inbounds for i in 1:N
664-
if dest[:, i] isa AbstractArray
664+
if dest[:, i] isa AbstractArray && !isa(dest[:, i], StaticArraysCore.SArray)
665665
copyto!(dest[:, i], unpack_voa(bc, i))
666666
else
667667
dest[:, i] = copy(unpack_voa(bc, i))

test/interface_tests.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,3 +117,11 @@ u = VectorOfArray([fill(2, SVector{2, Float64}), ones(SVector{2, Float64})])
117117
@test typeof(zero(u)) <: typeof(u)
118118
resize!(u,3)
119119
@test pointer(u) === pointer(u.u)
120+
121+
# Ensure broadcast (including assignment) works with StaticArrays
122+
x = VectorOfArray([fill(2, SVector{2, Float64}), ones(SVector{2, Float64})])
123+
y = VectorOfArray([fill(2, SVector{2, Float64}), ones(SVector{2, Float64})])
124+
z = VectorOfArray([zeros(SVector{2, Float64}), zeros(SVector{2, Float64})])
125+
z .= x .+ y
126+
127+
@test z == VectorOfArray([fill(4, SVector{2, Float64}), fill(2, SVector{2, Float64})])

0 commit comments

Comments
 (0)