Open
Description
Describe the bug 🐞
The @mtkmodel
macro expands to code which relies on certain names beeing presend in the calling context, for example Num
and Equation
. As of #3526 also System
(see this line)
This is breaking in contexts which use only implicit imports, for example I hadn't imported System
before. I guess everything should be called via ModelingToolkit.$sym
? But in general you cannot even assume that ModelingToolkit
is defined in the calling module...
Expected behavior
Only depend on using Modelingtoolkit: @mtkmodel
to use @mtkmodel
macro.
Minimal Reproducible Example 👇
using ModelingToolkit: ModelingToolkit, @mtkmodel, @variables, @parameters, t_nounits as t # those kinda make sense
using ModelingToolkit: Equation, Num, System # <- this is needed
@mtkmodel MyModel begin
@variables begin
x(t)
y(t)
end
@parameters begin
a
end
@equations begin
y ~ a * x
end
end
MyModel(; name=:foo)