diff --git a/Project.toml b/Project.toml index dcad7c5e4d..816c9a45ed 100644 --- a/Project.toml +++ b/Project.toml @@ -133,7 +133,7 @@ SpecialFunctions = "0.7, 0.8, 0.9, 0.10, 1.0, 2" StaticArrays = "0.10, 0.11, 0.12, 1.0" SymbolicIndexingInterface = "0.3.35" SymbolicUtils = "3.7" -Symbolics = "6.19" +Symbolics = "6.22" URIs = "1" UnPack = "0.1, 1.0" Unitful = "1.1" diff --git a/src/systems/model_parsing.jl b/src/systems/model_parsing.jl index 5b79eaa91b..d6cb47146b 100644 --- a/src/systems/model_parsing.jl +++ b/src/systems/model_parsing.jl @@ -497,7 +497,7 @@ function generate_var!(dict, a, b, varclass, mod; vd isa Vector && (vd = first(vd)) vd[a] = Dict{Symbol, Any}() var = if indices === nothing - Symbolics.variable(a, T = SymbolicUtils.FnType{Tuple{Any}, type})(iv) + first(@variables $a(iv)::type) else vd[a][:size] = Tuple(lastindex.(indices)) first(@variables $a(iv)[indices...]::type) diff --git a/test/model_parsing.jl b/test/model_parsing.jl index fd223800e3..46bf117bc2 100644 --- a/test/model_parsing.jl +++ b/test/model_parsing.jl @@ -1,4 +1,4 @@ -using ModelingToolkit, Test +using ModelingToolkit, Symbolics, Test using ModelingToolkit: get_connector_type, get_defaults, get_gui_metadata, get_systems, get_ps, getdefault, getname, readable_code, scalarize, symtype, VariableDescription, RegularConnector, @@ -979,3 +979,22 @@ end @test MultipleExtend.structure[:extend][1] == [:inmodel, :b, :inmodel_b] @test tosymbol.(parameters(multiple_extend)) == [:b, :inmodel_b₊p, :inmodel₊p] end + +@testset "Variables are not callable symbolics" begin + @mtkmodel Example begin + @variables begin + x(t) + y(t) + end + @equations begin + x ~ y + end + end + @named ex = Example() + vars = Symbolics.get_variables(only(equations(ex))) + @test length(vars) == 2 + for u in Symbolics.unwrap.(unknowns(ex)) + @test !Symbolics.hasmetadata(u, Symbolics.CallWithParent) + @test any(isequal(u), vars) + end +end