Skip to content

Commit 88463c4

Browse files
fix: fix renamespace for array variables
1 parent f628736 commit 88463c4

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/systems/abstractsystem.jl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -758,7 +758,7 @@ struct ParentScope <: SymScope
758758
end
759759
function ParentScope(sym::Union{Num, Symbolic, Symbolics.Arr{Num}})
760760
apply_to_variables(sym) do sym
761-
if istree(sym) && operation(sym) == getindex
761+
if istree(sym) && operation(sym) === getindex
762762
args = arguments(sym)
763763
a1 = setmetadata(args[1], SymScope,
764764
ParentScope(getmetadata(value(args[1]), SymScope, LocalScope())))
@@ -814,6 +814,11 @@ function renamespace(sys, x)
814814
return similarterm(x, operation(x),
815815
Any[renamespace(sys, only(arguments(x)))])::T
816816
end
817+
if istree(x) && operation(x) === getindex
818+
args = arguments(x)
819+
return similarterm(
820+
x, operation(x), vcat(renamespace(sys, args[1]), args[2:end]))::T
821+
end
817822
let scope = getmetadata(x, SymScope, LocalScope())
818823
if scope isa LocalScope
819824
rename(x, renamespace(getname(sys), getname(x)))::T

0 commit comments

Comments
 (0)