Skip to content

Commit 0abf0b1

Browse files
fix: fix potential Julia compilation bug on 1.10
1 parent ba589e5 commit 0abf0b1

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

lib/ModelingToolkitBase/ext/MTKDynamicQuantitiesExt.jl

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,18 @@ function __init__()
1717
only(@independent_variables t [unit = DQ.u"s"])
1818
end
1919
SymbolicUtils.hashcons(unwrap(MTK.t), true)
20-
return MTK.D = Differential(MTK.t)
20+
MTK.D = Differential(MTK.t)
21+
# Workaround for Julia 1.10 compiler bug
22+
# See https://github.com/SciML/ModelingToolkit.jl/issues/4211
23+
return @static if VERSION < v"1.11"
24+
# Force collect_var! compilation to fix collect_vars!
25+
@variables _dummy_t
26+
@parameters _dummy_p
27+
@variables _dummy_x(_dummy_t) = _dummy_p
28+
_us = OrderedSet{SymbolicT}()
29+
_ps = OrderedSet{SymbolicT}()
30+
MTK.collect_var!(_us, _ps, unwrap(_dummy_x), unwrap(_dummy_t); depth = 0)
31+
end
2132
end
2233
#For dispatching get_unit
2334
const Conditional = Union{typeof(ifelse)}

0 commit comments

Comments
 (0)