Skip to content

Conversation

@ChrisRackauckas-Claude
Copy link

Fixes #461

Summary

Fixes recursivefill! failure when called on a VectorOfArray containing immutable StaticArray types like SVector.

Problem

The recursivefill! function failed when called on a VectorOfArray containing immutable static arrays. The underlying Base.fill! implementation attempted in-place modification of immutable arrays, which is not supported.

Solution

Modified Base.fill! in src/vector_of_array.jl to check if each element array is mutable before attempting to fill it. For immutable arrays, we now create a new filled array using StaticArraysCore.similar_type and assign it.

Changes

  • Updated Base.fill! to handle both mutable and immutable arrays
  • Added comprehensive tests for mixed StaticArray types

All existing tests continue to pass.

🤖 Generated with Claude Code

Co-Authored-By: Claude noreply@anthropic.com

This commit fixes a bug where `recursivefill!` would fail when called on
a `VectorOfArray` containing immutable `StaticArray` types like `SVector`.

## Problem
The `Base.fill!` method for `AbstractVectorOfArray` attempted to call
`fill!` on each element array, which fails for immutable arrays that don't
support in-place modification via `setindex!`.

## Solution
Modified `Base.fill!` to check if each element is mutable before attempting
to fill it. For immutable arrays, we now create a new filled array using
`StaticArraysCore.similar_type` and assign it, following the same pattern
used in the existing `copyto!` implementation.

## Changes
- Updated `Base.fill!` in `src/vector_of_array.jl` to handle both mutable
  and immutable arrays correctly
- Added comprehensive tests in `test/utils_test.jl` to cover:
  - `VectorOfArray` with only immutable `SVector`s
  - `VectorOfArray` with mixed immutable and mutable `StaticArray`s
  - Both `recursivefill!` and `fill!` methods

All existing tests continue to pass.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@ChrisRackauckas ChrisRackauckas merged commit 9193003 into SciML:master Oct 24, 2025
15 of 25 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.

Bug: recursivefill! fails on VectorOfArray with mixed immutable and mutable StaticArrays

2 participants