From 63f56d524409613951f69b7d63bfcfee52eb4773 Mon Sep 17 00:00:00 2001 From: ChrisRackauckas-Claude Date: Sat, 8 Aug 2026 20:27:34 -0400 Subject: [PATCH 1/2] Fix RaggedArrays immutable storage inference Co-Authored-By: Chris Rackauckas --- .../Project.toml | 4 +++- .../src/RecursiveArrayToolsRaggedArrays.jl | 8 ++++---- .../test/qa/qa.jl | 11 +---------- .../test/runtests.jl | 19 +++++++++++++++++++ 4 files changed, 27 insertions(+), 15 deletions(-) diff --git a/lib/RecursiveArrayToolsRaggedArrays/Project.toml b/lib/RecursiveArrayToolsRaggedArrays/Project.toml index 4c6a690f..683b75e7 100644 --- a/lib/RecursiveArrayToolsRaggedArrays/Project.toml +++ b/lib/RecursiveArrayToolsRaggedArrays/Project.toml @@ -20,6 +20,7 @@ LinearAlgebra = "1.10" Pkg = "1" RecursiveArrayTools = "4" SparseArrays = "1.10" +StaticArrays = "1.6" StaticArraysCore = "1.4.2" SymbolicIndexingInterface = "0.3.42" Test = "1" @@ -28,8 +29,9 @@ julia = "1.10" [extras] Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" +StaticArrays = "90137ffa-7385-5640-81b9-e52037218182" SymbolicIndexingInterface = "2efcf032-c050-4f8e-a9bb-153293bab1f5" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" [targets] -test = ["Pkg", "SparseArrays", "SymbolicIndexingInterface", "Test"] +test = ["Pkg", "SparseArrays", "StaticArrays", "SymbolicIndexingInterface", "Test"] diff --git a/lib/RecursiveArrayToolsRaggedArrays/src/RecursiveArrayToolsRaggedArrays.jl b/lib/RecursiveArrayToolsRaggedArrays/src/RecursiveArrayToolsRaggedArrays.jl index 4b48e38b..8c334145 100644 --- a/lib/RecursiveArrayToolsRaggedArrays/src/RecursiveArrayToolsRaggedArrays.jl +++ b/lib/RecursiveArrayToolsRaggedArrays/src/RecursiveArrayToolsRaggedArrays.jl @@ -1322,7 +1322,7 @@ function Base.copyto!( if ArrayInterface.ismutable(dest.u[i]) || dest.u[i] isa AbstractRaggedVectorOfArray copyto!(dest.u[i], src.u[j]) else - dest.u[i] = StaticArraysCore.similar_type(dest.u[i])(src.u[j]) + dest.u[i] = typeof(dest.u[i])(src.u[j]) end end return @@ -1334,7 +1334,7 @@ function Base.copyto!( if ArrayInterface.ismutable(dest.u[i]) || dest.u[i] isa AbstractRaggedVectorOfArray copyto!(dest.u[i], slice) else - dest.u[i] = StaticArraysCore.similar_type(dest.u[i])(slice) + dest.u[i] = typeof(dest.u[i])(slice) end end return dest @@ -1455,7 +1455,7 @@ function Base.fill!(VA::AbstractRaggedVectorOfArray, x) fill!(VA[:, i], x) else # For immutable arrays like SVector, create a new filled array - VA.u[i] = fill(x, StaticArraysCore.similar_type(VA.u[i])) + VA.u[i] = typeof(VA.u[i])(fill(x, size(VA.u[i]))) end else VA[:, i] = x @@ -1623,7 +1623,7 @@ for (type, N_expr) in [ copyto!(dest[:, i], unpack_voa(bc, i)) else unpacked = unpack_voa(bc, i) - arr_type = StaticArraysCore.similar_type(dest[:, i]) + arr_type = typeof(dest[:, i]) dest[:, i] = if length(unpacked) == 1 && length(dest[:, i]) == 1 arr_type(unpacked[1]) elseif length(unpacked) == 1 diff --git a/lib/RecursiveArrayToolsRaggedArrays/test/qa/qa.jl b/lib/RecursiveArrayToolsRaggedArrays/test/qa/qa.jl index f43eec28..4f85da54 100644 --- a/lib/RecursiveArrayToolsRaggedArrays/test/qa/qa.jl +++ b/lib/RecursiveArrayToolsRaggedArrays/test/qa/qa.jl @@ -15,15 +15,6 @@ run_qa( ), ), jet_kwargs = (; target_modules = (RecursiveArrayToolsRaggedArrays,)), - # Pre-existing JET typo-mode finding (reproduces byte-identically on master): - # the `copyto!`/`fill!`/broadcast immutable-element branches call - # `StaticArraysCore.similar_type(dest.u[i])`, but `dest.u[i]` infers as `::Any` - # because the abstract `AbstractRaggedVectorOfArray` `.u` field is untyped, so - # `similar_type(::Any)` has no matching method. Tracked (with the real fix — - # tightening the `.u` type / guarding the immutable branch) in - # https://github.com/SciML/RecursiveArrayTools.jl/issues/620. JET 0.9 on Julia - # 1.10 does not report this finding, so keep that stricter lane unbroken. - jet_broken = VERSION >= v"1.11", ei_kwargs = (; # Non-public names legitimately qualified/imported from upstream packages # (Base, Base.Broadcast, StaticArraysCore, ArrayInterface, Adapt, @@ -35,7 +26,7 @@ run_qa( :Slice, :SolvedVariables, :StaticVecOrMat, :SymbolicTypeTrait, :adapt_structure, :add_sum, :broadcastable, :check_parent_index_match, :ensure_indexable, :flatten, :front, :index_dimsum, :ismutable, - :issingular, :maybeview, :mul_prod, :similar_type, :tail, :typename, + :issingular, :maybeview, :mul_prod, :tail, :typename, :unalias, :viewindexing, ), ), diff --git a/lib/RecursiveArrayToolsRaggedArrays/test/runtests.jl b/lib/RecursiveArrayToolsRaggedArrays/test/runtests.jl index 2c56aa4e..96a37de9 100644 --- a/lib/RecursiveArrayToolsRaggedArrays/test/runtests.jl +++ b/lib/RecursiveArrayToolsRaggedArrays/test/runtests.jl @@ -2,6 +2,7 @@ using RecursiveArrayTools, RecursiveArrayToolsRaggedArrays using RecursiveArrayToolsRaggedArrays: RaggedEnd, RaggedRange using SymbolicIndexingInterface using SymbolicIndexingInterface: SymbolCache +using StaticArrays using Test using Pkg @@ -25,6 +26,24 @@ end if TEST_GROUP == "Core" || TEST_GROUP == "All" @testset "RecursiveArrayToolsRaggedArrays" begin + @testset "immutable inner arrays" begin + src = RaggedVectorOfArray([SVector(1, 2), SVector(3, 4)]) + dest = RaggedVectorOfArray([SVector(0, 0), SVector(0, 0)]) + + copyto!(dest, src) + @test dest.u == src.u + @test eltype(dest.u) === SVector{2, Int} + + copyto!(dest, [5 7; 6 8]) + @test dest.u == [SVector(5, 6), SVector(7, 8)] + + fill!(dest, 9) + @test dest.u == [SVector(9, 9), SVector(9, 9)] + + dest .= src .+ 1 + @test dest.u == [SVector(2, 3), SVector(4, 5)] + end + # =================================================================== # Tests ported from v3 basic_indexing.jl # =================================================================== From 64aec81e02f30986aa34d4a674f565f42079f2c4 Mon Sep 17 00:00:00 2001 From: ChrisRackauckas-Claude Date: Sat, 8 Aug 2026 21:12:28 -0400 Subject: [PATCH 2/2] Run monorepo tests without source overrides Co-Authored-By: Chris Rackauckas --- .../Project.toml | 3 --- .../test/runtests.jl | 4 +++- lib/RecursiveArrayToolsRaggedArrays/Project.toml | 3 --- lib/RecursiveArrayToolsRaggedArrays/test/runtests.jl | 4 +++- .../Project.toml | 3 --- .../test/runtests.jl | 4 +++- test/AD/Project.toml | 3 --- test/Downstream/Project.toml | 4 ---- test/GPU/Project.toml | 4 ---- test/NoPre/Project.toml | 3 --- test/runtests.jl | 10 ++++++++++ 11 files changed, 19 insertions(+), 26 deletions(-) diff --git a/lib/RecursiveArrayToolsArrayPartitionAnyAll/Project.toml b/lib/RecursiveArrayToolsArrayPartitionAnyAll/Project.toml index e89374e9..ccdab349 100644 --- a/lib/RecursiveArrayToolsArrayPartitionAnyAll/Project.toml +++ b/lib/RecursiveArrayToolsArrayPartitionAnyAll/Project.toml @@ -5,9 +5,6 @@ version = "1.0.2" [deps] RecursiveArrayTools = "731186ca-8d62-57ce-b412-fbd966d074cd" -[sources] -RecursiveArrayTools = {path = "../.."} - [compat] Pkg = "1" RecursiveArrayTools = "4" diff --git a/lib/RecursiveArrayToolsArrayPartitionAnyAll/test/runtests.jl b/lib/RecursiveArrayToolsArrayPartitionAnyAll/test/runtests.jl index 4f2aa9b6..1730c47b 100644 --- a/lib/RecursiveArrayToolsArrayPartitionAnyAll/test/runtests.jl +++ b/lib/RecursiveArrayToolsArrayPartitionAnyAll/test/runtests.jl @@ -1,5 +1,7 @@ -using RecursiveArrayTools, RecursiveArrayToolsArrayPartitionAnyAll, Test using Pkg +Pkg.develop(PackageSpec(path = normpath(joinpath(@__DIR__, "..", "..", "..")))) + +using RecursiveArrayTools, RecursiveArrayToolsArrayPartitionAnyAll, Test const TEST_GROUP = get(ENV, "RECURSIVEARRAYTOOLS_TEST_GROUP", "Core") diff --git a/lib/RecursiveArrayToolsRaggedArrays/Project.toml b/lib/RecursiveArrayToolsRaggedArrays/Project.toml index 683b75e7..2376b6b1 100644 --- a/lib/RecursiveArrayToolsRaggedArrays/Project.toml +++ b/lib/RecursiveArrayToolsRaggedArrays/Project.toml @@ -10,9 +10,6 @@ RecursiveArrayTools = "731186ca-8d62-57ce-b412-fbd966d074cd" StaticArraysCore = "1e83bf80-4336-4d27-bf5d-d5a4f845583c" SymbolicIndexingInterface = "2efcf032-c050-4f8e-a9bb-153293bab1f5" -[sources] -RecursiveArrayTools = {path = "../.."} - [compat] Adapt = "4" ArrayInterface = "7.17.0" diff --git a/lib/RecursiveArrayToolsRaggedArrays/test/runtests.jl b/lib/RecursiveArrayToolsRaggedArrays/test/runtests.jl index 96a37de9..da009fab 100644 --- a/lib/RecursiveArrayToolsRaggedArrays/test/runtests.jl +++ b/lib/RecursiveArrayToolsRaggedArrays/test/runtests.jl @@ -1,10 +1,12 @@ +using Pkg +Pkg.develop(PackageSpec(path = normpath(joinpath(@__DIR__, "..", "..", "..")))) + using RecursiveArrayTools, RecursiveArrayToolsRaggedArrays using RecursiveArrayToolsRaggedArrays: RaggedEnd, RaggedRange using SymbolicIndexingInterface using SymbolicIndexingInterface: SymbolCache using StaticArrays using Test -using Pkg const TEST_GROUP = get(ENV, "RECURSIVEARRAYTOOLS_TEST_GROUP", "Core") diff --git a/lib/RecursiveArrayToolsShorthandConstructors/Project.toml b/lib/RecursiveArrayToolsShorthandConstructors/Project.toml index 38da5443..cd32ae59 100644 --- a/lib/RecursiveArrayToolsShorthandConstructors/Project.toml +++ b/lib/RecursiveArrayToolsShorthandConstructors/Project.toml @@ -5,9 +5,6 @@ version = "1.0.2" [deps] RecursiveArrayTools = "731186ca-8d62-57ce-b412-fbd966d074cd" -[sources] -RecursiveArrayTools = {path = "../.."} - [compat] Pkg = "1" RecursiveArrayTools = "4" diff --git a/lib/RecursiveArrayToolsShorthandConstructors/test/runtests.jl b/lib/RecursiveArrayToolsShorthandConstructors/test/runtests.jl index c708d4df..940fa742 100644 --- a/lib/RecursiveArrayToolsShorthandConstructors/test/runtests.jl +++ b/lib/RecursiveArrayToolsShorthandConstructors/test/runtests.jl @@ -1,5 +1,7 @@ -using RecursiveArrayTools, RecursiveArrayToolsShorthandConstructors, Test using Pkg +Pkg.develop(PackageSpec(path = normpath(joinpath(@__DIR__, "..", "..", "..")))) + +using RecursiveArrayTools, RecursiveArrayToolsShorthandConstructors, Test const TEST_GROUP = get(ENV, "RECURSIVEARRAYTOOLS_TEST_GROUP", "Core") diff --git a/test/AD/Project.toml b/test/AD/Project.toml index dbbef75e..36bc7f57 100644 --- a/test/AD/Project.toml +++ b/test/AD/Project.toml @@ -6,9 +6,6 @@ ReverseDiff = "37e2e3b7-166d-5795-8a7a-e32c996b4267" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f" -[sources] -RecursiveArrayTools = {path = "../.."} - [compat] ForwardDiff = "0.10.38, 1" Mooncake = "0.5" diff --git a/test/Downstream/Project.toml b/test/Downstream/Project.toml index df435b37..aea6ec28 100644 --- a/test/Downstream/Project.toml +++ b/test/Downstream/Project.toml @@ -15,10 +15,6 @@ Tracker = "9f7883ad-71c0-57eb-9f7f-b5c9e6d3789c" Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d" Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f" -[sources] -RecursiveArrayTools = {path = "../.."} -RecursiveArrayToolsShorthandConstructors = {path = "../../lib/RecursiveArrayToolsShorthandConstructors"} - [compat] ArrayInterface = "7" ModelingToolkit = "8.33, 9, 10, 11" diff --git a/test/GPU/Project.toml b/test/GPU/Project.toml index 6a151241..04680ee8 100644 --- a/test/GPU/Project.toml +++ b/test/GPU/Project.toml @@ -8,10 +8,6 @@ RecursiveArrayToolsArrayPartitionAnyAll = "172d604e-c495-4f00-97bf-d70957099afa" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f" -[sources] -RecursiveArrayTools = {path = "../.."} -RecursiveArrayToolsArrayPartitionAnyAll = {path = "../../lib/RecursiveArrayToolsArrayPartitionAnyAll"} - [compat] Adapt = "4" ArrayInterface = "7.17.0" diff --git a/test/NoPre/Project.toml b/test/NoPre/Project.toml index f289409f..67d5a25c 100644 --- a/test/NoPre/Project.toml +++ b/test/NoPre/Project.toml @@ -3,9 +3,6 @@ JET = "c3a54625-cd67-489e-a8e7-0a5a0ff4e31b" RecursiveArrayTools = "731186ca-8d62-57ce-b412-fbd966d074cd" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" -[sources] -RecursiveArrayTools = {path = "../.."} - [compat] JET = "0.9, 0.10, 0.11" RecursiveArrayTools = "4" diff --git a/test/runtests.jl b/test/runtests.jl index 1c949610..0e315888 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -36,12 +36,20 @@ run_tests(; # second half of both the "SymbolicIndexingInterface" and "Downstream" paths. "SII_Downstream" => (; env = joinpath(@__DIR__, "Downstream"), + parent = [ + dirname(@__DIR__), + joinpath(dirname(@__DIR__), "lib", "RecursiveArrayToolsShorthandConstructors"), + ], body = function () return @time @safetestset "DiffEqArray Indexing Tests" include("Downstream/symbol_indexing.jl") end, ), "Downstream" => (; env = joinpath(@__DIR__, "Downstream"), + parent = [ + dirname(@__DIR__), + joinpath(dirname(@__DIR__), "lib", "RecursiveArrayToolsShorthandConstructors"), + ], body = function () @time @safetestset "ODE Solve Tests" include("Downstream/odesolve.jl") @time @safetestset "Event Tests with ArrayPartition" include("Downstream/downstream_events.jl") @@ -65,6 +73,7 @@ run_tests(; ), "NoPre" => (; env = joinpath(@__DIR__, "NoPre"), + parent = dirname(@__DIR__), body = function () return @time @safetestset "JET Tests" include("NoPre/jet_tests.jl") end, @@ -76,6 +85,7 @@ run_tests(; # cannot satisfy when it minimizes Julia to the 1.10.0 LTS floor. "AD" => (; env = joinpath(@__DIR__, "AD"), + parent = dirname(@__DIR__), body = function () @time @safetestset "Adjoint Tests" include("AD/adjoints.jl") return @time @safetestset "Mooncake Tests" include("AD/mooncake.jl")