Skip to content

Commit 273a065

Browse files
Preserve container type in zero(VectorOfArray) via rewrap
`[zero(u) for u in VA.u]` always produces a plain `Vector`, even when `VA.u` is a `StructVector` (from StructArrays.jl). The constructor then fails with `MethodError: Cannot convert Vector{SVector{1,Float64}} to StructVector{...}` because the type parameter `A` is locked to the original container type. Use the existing `rewrap(parent, u)` mechanism (already used by broadcast) to convert the comprehension result back to the original container type. The `StructArrays` extension defines `rewrap(::StructArray, u) = StructArray(u)`, and the fallback is `convert(typeof(parent), u)`. Fixes OrdinaryDiffEq.jl v7 CI failures in OrdinaryDiffEqLowStorageRK and OrdinaryDiffEqSSPRK "VectorOfArray/StructArray compatibility" tests. Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com> Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 25b5e64 commit 273a065

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

src/vector_of_array.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -945,7 +945,7 @@ end
945945

946946
function Base.zero(VA::AbstractVectorOfArray)
947947
T = typeof(VA)
948-
u_zero = [zero(u) for u in VA.u]
948+
u_zero = rewrap(VA.u, [zero(u) for u in VA.u])
949949
fields = [fname == :u ? u_zero : _copyfield(VA, fname) for fname in fieldnames(T)]
950950
return T(fields...)
951951
end

0 commit comments

Comments
 (0)