From 2b5562893880f6d2ca11a4e8898bf7a6a0d39ea5 Mon Sep 17 00:00:00 2001 From: Aayush Sabharwal Date: Sun, 17 Aug 2025 13:07:08 +0530 Subject: [PATCH] fix: fix callback with non-`Real` parameter and non-empty unknowns --- src/systems/callbacks.jl | 2 +- test/symbolic_events.jl | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/systems/callbacks.jl b/src/systems/callbacks.jl index a97ab2d233..f344f33d39 100644 --- a/src/systems/callbacks.jl +++ b/src/systems/callbacks.jl @@ -855,7 +855,7 @@ end function default_operating_point(affsys::AffectSystem) sys = system(affsys) - op = Dict(unknowns(sys) .=> 0.0) + op = AnyDict(unknowns(sys) .=> 0.0) for p in parameters(sys) T = symtype(p) if T <: Number diff --git a/test/symbolic_events.jl b/test/symbolic_events.jl index cf90ccd283..5f37e524e1 100644 --- a/test/symbolic_events.jl +++ b/test/symbolic_events.jl @@ -1421,3 +1421,22 @@ end @named sys = System([D(y) ~ 2x + 1, x^2 ~ 2y^3], t; discrete_events = [dev]) sys = @test_nowarn mtkcompile(sys) end + +@testset "Non-`Real` symtype parameters in callback with unknown" begin + @mtkmodel MWE begin + @variables begin + x(t) = 1.0 + end + @parameters begin + p(t)::Int = 1 + end + @equations begin + D(x) ~ p * x + end + @discrete_events begin + 1.0 => [x ~ p * Pre(x) * sin(x)] + end + end + @mtkcompile sys = MWE() + @test_nowarn ODEProblem(sys, [], (0.0, 1.0)) +end