Skip to content

Commit 677925b

Browse files
fix: fix renamespace for array variables
1 parent e24b188 commit 677925b

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
@@ -763,7 +763,7 @@ struct ParentScope <: SymScope
763763
end
764764
function ParentScope(sym::Union{Num, Symbolic, Symbolics.Arr{Num}})
765765
apply_to_variables(sym) do sym
766-
if istree(sym) && operation(sym) == getindex
766+
if istree(sym) && operation(sym) === getindex
767767
args = arguments(sym)
768768
a1 = setmetadata(args[1], SymScope,
769769
ParentScope(getmetadata(value(args[1]), SymScope, LocalScope())))
@@ -819,6 +819,11 @@ function renamespace(sys, x)
819819
return similarterm(x, operation(x),
820820
Any[renamespace(sys, only(arguments(x)))])::T
821821
end
822+
if istree(x) && operation(x) === getindex
823+
args = arguments(x)
824+
return similarterm(
825+
x, operation(x), vcat(renamespace(sys, args[1]), args[2:end]))::T
826+
end
822827
let scope = getmetadata(x, SymScope, LocalScope())
823828
if scope isa LocalScope
824829
rename(x, renamespace(getname(sys), getname(x)))::T

0 commit comments

Comments
 (0)