Skip to content

Commit 3e4a22f

Browse files
fix: allow setting VoA of SArray using scalars
1 parent 9b152ff commit 3e4a22f

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/vector_of_array.jl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -681,7 +681,12 @@ end
681681
copyto!(dest[:, i], unpack_voa(bc, i))
682682
else
683683
unpacked = unpack_voa(bc, i)
684-
dest[:, i] = unpacked.f(unpacked.args...)
684+
value = unpacked.f(unpacked.args...)
685+
dest[:, i] = if value isa Number && dest[:, i] isa AbstractArray
686+
fill(value, StaticArraysCore.similar_type(dest[:, i]))
687+
else
688+
value
689+
end
685690
end
686691
end
687692
dest

test/interface_tests.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,3 +149,6 @@ function f!(z,zz)
149149
end
150150
f!(z,zz)
151151
@test (@allocated f!(z,zz)) == 0
152+
153+
z .= 0.1
154+
@test z == VectorOfArray([fill(0.1, SVector{2, Float64}), fill(0.1, SVector{2, Float64})])

0 commit comments

Comments
 (0)