Skip to content

Commit

Permalink
Don't drop metadata during array indexing operation
Browse files Browse the repository at this point in the history
Attach scope metatdata on indexing operation to array so renaming works
correctly.
  • Loading branch information
contradict committed Nov 12, 2023
1 parent 2f13d13 commit 560dbc0
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/systems/abstractsystem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -503,8 +503,13 @@ function namespace_expr(O, sys, n = nameof(sys); ivs = independent_variables(sys
return O
elseif istree(O)
T = typeof(O)
op = operation(O)
args = arguments(O)
if op == getindex && hasmetadata(O, SymScope)
args[1] = setmetadata(args[1], SymScope, getmetadata(O, SymScope))

Check warning on line 509 in src/systems/abstractsystem.jl

View check run for this annotation

Codecov / codecov/patch

src/systems/abstractsystem.jl#L506-L509

Added lines #L506 - L509 were not covered by tests
end
renamed = let sys = sys, n = n, T = T
map(a -> namespace_expr(a, sys, n; ivs)::Any, arguments(O))
map(a -> namespace_expr(a, sys, n; ivs)::Any, args)

Check warning on line 512 in src/systems/abstractsystem.jl

View check run for this annotation

Codecov / codecov/patch

src/systems/abstractsystem.jl#L512

Added line #L512 was not covered by tests
end
if isvariable(O)
# Use renamespace so the scope is correct, and make sure to use the
Expand Down

0 comments on commit 560dbc0

Please sign in to comment.