diff --git a/src/vector_of_array.jl b/src/vector_of_array.jl index f54139eb..0b10012c 100644 --- a/src/vector_of_array.jl +++ b/src/vector_of_array.jl @@ -661,7 +661,7 @@ end bc = Broadcast.flatten(bc) N = narrays(bc) @inbounds for i in 1:N - if dest[:, i] isa AbstractArray + if dest[:, i] isa AbstractArray && !isa(dest[:, i], StaticArraysCore.SArray) copyto!(dest[:, i], unpack_voa(bc, i)) else dest[:, i] = copy(unpack_voa(bc, i)) diff --git a/test/interface_tests.jl b/test/interface_tests.jl index b27c7068..4f79c3e6 100644 --- a/test/interface_tests.jl +++ b/test/interface_tests.jl @@ -117,3 +117,11 @@ u = VectorOfArray([fill(2, SVector{2, Float64}), ones(SVector{2, Float64})]) @test typeof(zero(u)) <: typeof(u) resize!(u,3) @test pointer(u) === pointer(u.u) + +# Ensure broadcast (including assignment) works with StaticArrays +x = VectorOfArray([fill(2, SVector{2, Float64}), ones(SVector{2, Float64})]) +y = VectorOfArray([fill(2, SVector{2, Float64}), ones(SVector{2, Float64})]) +z = VectorOfArray([zeros(SVector{2, Float64}), zeros(SVector{2, Float64})]) +z .= x .+ y + +@test z == VectorOfArray([fill(4, SVector{2, Float64}), fill(2, SVector{2, Float64})])