Commit 059ae4d
Fix recursivefill! failure with immutable StaticArrays (issue #461)
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>1 parent 711daaf commit 059ae4d
2 files changed
+35
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
826 | 826 | | |
827 | 827 | | |
828 | 828 | | |
829 | | - | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
830 | 835 | | |
831 | 836 | | |
832 | 837 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
139 | 139 | | |
140 | 140 | | |
141 | 141 | | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
142 | 171 | | |
143 | 172 | | |
144 | 173 | | |
| |||
0 commit comments