Skip to content

Commit 338e20f

Browse files
fix: do not mutate decomposition subsystems in SCCNonlinearProblem
1 parent fc3db87 commit 338e20f

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

src/problems/sccnonlinearproblem.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,10 @@ function build_caches!(sys::System, decomposition::SCCDecomposition)
296296
push!(banned_vars, split_indexed_var(u)[1])
297297
end
298298

299-
_eqs = get_eqs(subsys)
299+
# While we own the system and so mutation _should_ be safe, `IRInfo` exists.
300+
# It stores the indices corresponding to equations in the `IRStructure`, which
301+
# would be incorrect if we mutate.
302+
_eqs = copy(get_eqs(subsys))
300303
exprs_to_search = SymbolicT[]
301304
for i in eachindex(_eqs)
302305
push!(exprs_to_search, _eqs[i].rhs)
@@ -306,6 +309,7 @@ function build_caches!(sys::System, decomposition::SCCDecomposition)
306309
for i in eachindex(_eqs)
307310
_eqs[i] = _eqs[i].lhs ~ subber(_eqs[i].rhs)
308311
end
312+
subsys = decomposition.subsystems[i] = ConstructionBase.setproperties(subsys; eqs = _eqs)
309313

310314
if decomposition.islinear[i]
311315
store_to_mutable_cache!(subsys, CachedLinearAb, nothing)

0 commit comments

Comments
 (0)