Skip to content

Commit 3e4247e

Browse files
committed
Add test and fix typo
1 parent af79dfa commit 3e4247e

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/systems/abstractsystem.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -358,12 +358,13 @@ function Base.setproperty!(sys::AbstractSystem, prop::Symbol, val)
358358
end
359359

360360
function apply_to_variables(f::F, ex) where {F}
361+
ex = value(ex)
361362
if isvariable(ex)
362363
return f(ex)
363364
end
364365
istree(ex) || return ex
365-
similarterm(ex, apply_to_variables(operation(ex)),
366-
map(apply_to_variables, arguments(ex)),
366+
similarterm(ex, apply_to_variables(f, operation(ex)),
367+
map(Base.Fix1(apply_to_variables, f), arguments(ex)),
367368
metadata = metadata(ex))
368369
end
369370

test/variable_scope.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
using ModelingToolkit
2+
using ModelingToolkit: SymScope
3+
using Symbolics: arguments, value
24
using Test
35

46
@parameters t
@@ -13,6 +15,9 @@ LocalScope(e.val)
1315
ParentScope(e.val)
1416
GlobalScope(e.val)
1517

18+
ie = ParentScope(1 / e)
19+
@test getmetadata(arguments(value(ie))[2], SymScope) === ParentScope(LocalScope())
20+
1621
eqs = [0 ~ a
1722
0 ~ b
1823
0 ~ c

0 commit comments

Comments
 (0)