Skip to content

Commit e7df8d4

Browse files
fix scoping
1 parent e24bd29 commit e7df8d4

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/systems/abstractsystem.jl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -501,8 +501,11 @@ function namespace_expr(O, sys, n = nameof(sys))
501501
map(a -> namespace_expr(a, sys, n)::Any, arguments(O))
502502
end
503503
if isvariable(O)
504-
similarterm(O, renamespace(n, operation(O)), renamed,
505-
metadata = metadata(O))::T
504+
# Use renamespace so the scope is correct, and make sure to use the
505+
# metadata from the rescoped variable
506+
rescoped = renamespace(n, O)
507+
similarterm(O, operation(rescoped), renamed,
508+
metadata = metadata(rescoped))::T
506509
else
507510
similarterm(O, operation(O), renamed, metadata = metadata(O))::T
508511
end

0 commit comments

Comments
 (0)