From 0c6cf0701e32aacca154f4744838dd3c88ffb1d9 Mon Sep 17 00:00:00 2001 From: Aayush Sabharwal Date: Thu, 24 Jul 2025 19:30:37 +0530 Subject: [PATCH] fix: fix `@mtkbuild` not working when `@mtkcompile` is not imported --- src/deprecations.jl | 3 ++- test/odesystem.jl | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/deprecations.jl b/src/deprecations.jl index 6e8ea23b1c..d5e044801a 100644 --- a/src/deprecations.jl +++ b/src/deprecations.jl @@ -5,7 +5,8 @@ macro mtkbuild(exprs...) return quote Base.depwarn("`@mtkbuild` is deprecated. Use `@mtkcompile` instead.", :mtkbuild) - @mtkcompile $(exprs...) + $(Expr(:macrocall, var"@mtkcompile", + LineNumberNode(@__LINE__, @__FILE__), exprs...)) end |> esc end diff --git a/test/odesystem.jl b/test/odesystem.jl index 2e3bca34e2..438e5e7c10 100644 --- a/test/odesystem.jl +++ b/test/odesystem.jl @@ -1615,3 +1615,12 @@ end @test_nowarn push!(arr, sys) @test_nowarn TestWrapper(sys) end + +# ensure `@mtkbuild` works when `@mtkcompile` is not imported +module MtkbuildTestModule +import ModelingToolkit: @variables, System, t_nounits as t, D_nounits as D, @mtkbuild +import Test: @test +@variables x(t) +@mtkbuild sys = System(D(x) ~ t, t) +@test sys isa System +end