Fix recursivefill! failure with immutable StaticArrays#493
Merged
ChrisRackauckas merged 1 commit intoSciML:masterfrom Oct 24, 2025
Merged
Conversation
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
approved these changes
Oct 24, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #461
Summary
Fixes
recursivefill!failure when called on aVectorOfArraycontaining immutableStaticArraytypes likeSVector.Problem
The
recursivefill!function failed when called on aVectorOfArraycontaining immutable static arrays. The underlyingBase.fill!implementation attempted in-place modification of immutable arrays, which is not supported.Solution
Modified
Base.fill!insrc/vector_of_array.jlto check if each element array is mutable before attempting to fill it. For immutable arrays, we now create a new filled array usingStaticArraysCore.similar_typeand assign it.Changes
Base.fill!to handle both mutable and immutable arraysAll existing tests continue to pass.
🤖 Generated with Claude Code
Co-Authored-By: Claude noreply@anthropic.com