diff --git a/src/systems/systemstructure.jl b/src/systems/systemstructure.jl index 2841acf711..5e33a2da5a 100644 --- a/src/systems/systemstructure.jl +++ b/src/systems/systemstructure.jl @@ -928,7 +928,7 @@ function mtkcompile!(state::TearingState; simplify = false, time_domains = merge(Dict(state.fullvars .=> ci.var_domain), Dict(default_toterm.(state.fullvars) .=> ci.var_domain)) tss, clocked_inputs, continuous_id, id_to_clock = ModelingToolkit.split_system(ci) - if continuous_id == 0 + if !isempty(tss) && continuous_id == 0 # do a trait check here - handle fully discrete system additional_passes = get(kwargs, :additional_passes, nothing) if !isnothing(additional_passes) && any(discrete_compile_pass, additional_passes) diff --git a/test/odesystem.jl b/test/odesystem.jl index e054666d92..3b9693241c 100644 --- a/test/odesystem.jl +++ b/test/odesystem.jl @@ -1628,3 +1628,9 @@ import Test: @test @mtkbuild sys = System(D(x) ~ t, t) @test sys isa System end + +@testset "Empty system can be simplified" begin + @named sys = System(Equation[], t) + ss = mtkcompile(sys) + @test length(equations(ss)) == length(unknowns(ss)) == 0 +end