Skip to content

Commit a4ba071

Browse files
committed
Fix @mtkmodel to work without using ModelingToolkit
See #3640 Feels like `const MTK = ModelingToolkit` should be at the top-level for convenience.
1 parent 60c95b9 commit a4ba071

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/systems/model_parsing.jl

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,9 @@ function flatten_equations(eqs::Vector{Union{Equation, Vector{Equation}}})
4242
end
4343

4444
function _model_macro(mod, fullname::Union{Expr, Symbol}, expr, isconnector)
45+
MTK = ModelingToolkit
4546
if fullname isa Symbol
46-
name, type = fullname, :System
47+
name, type = fullname, :($MTK.System)
4748
else
4849
if fullname.head == :(::)
4950
name, type = fullname.args
@@ -74,9 +75,9 @@ function _model_macro(mod, fullname::Union{Expr, Symbol}, expr, isconnector)
7475
push!(exprs.args, :(parameters = []))
7576
# We build `System` by default; vectors can't be created for `System` as it is
7677
# a function.
77-
push!(exprs.args, :(systems = ModelingToolkit.AbstractSystem[]))
78-
push!(exprs.args, :(equations = Union{Equation, Vector{Equation}}[]))
79-
push!(exprs.args, :(defaults = Dict{Num, Union{Number, Symbol, Function}}()))
78+
push!(exprs.args, :(systems = $MTK.AbstractSystem[]))
79+
push!(exprs.args, :(equations = Union{$MTK.Equation, Vector{$MTK.Equation}}[]))
80+
push!(exprs.args, :(defaults = Dict{$MTK.Num, Union{Number, Symbol, Function}}()))
8081

8182
Base.remove_linenums!(expr)
8283
for arg in expr.args

0 commit comments

Comments
 (0)