Skip to content

Fix recursivecopy for VectorOfArray with immutable outer storage - #636

Merged
ChrisRackauckas merged 1 commit into
SciML:masterfrom
ChrisRackauckas-Claude:fix/recursivecopy-immutable-outer-voa
Jul 24, 2026
Merged

Fix recursivecopy for VectorOfArray with immutable outer storage#636
ChrisRackauckas merged 1 commit into
SciML:masterfrom
ChrisRackauckas-Claude:fix/recursivecopy-immutable-outer-voa

Conversation

@ChrisRackauckas-Claude

Copy link
Copy Markdown
Member

Summary

recursivecopy(::AbstractVectorOfArray) previously did b.u .= recursivecopy.(a.u). That fails when the outer container is immutable (e.g. SVector of arrays) because setindex! is undefined on SVector.

When the outer storage is immutable, rebuild via rewrap (same pattern as Base.zero), so the deep copy preserves the outer type and does not share inner arrays.

This is the remaining failure for OrdinaryDiffEq.jl#1365 after zero.(Q) already preserved SVector outer storage.

Test plan

  • Unit test: recursivecopy(VectorOfArray(SVector{2}([randn(5), randn(5)]))) preserves type, deep-copies inners
  • Unit test: mutable outer Vector path still deep-copies
  • Local minimal repro PASS
  • CI Core / utils tests

This PR should be ignored until reviewed by @ChrisRackauckas.

When the outer container is immutable (e.g. SVector of arrays),
`b.u .= recursivecopy.(a.u)` fails because setindex! is undefined.
Rebuild via rewrap, matching Base.zero, so recursivecopy deep-copies
and preserves the outer type.

Fixes the remaining failure path for SciML/OrdinaryDiffEq.jl#1365.

Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
@ChrisRackauckas
ChrisRackauckas marked this pull request as ready for review July 24, 2026 06:14
@ChrisRackauckas
ChrisRackauckas merged commit 8d8c6a2 into SciML:master Jul 24, 2026
43 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants