Skip to content

Commit 225fb55

Browse files
authored
Do not attempt to promote to Union
Sometimes `symtype` returns a union like `Union{Float64, Int64}` ```julia julia> @variables x::Float64 1-element Vector{Num}: x julia> ModelingToolkit.symtype(ifelse(x > 0, x, 0)) Union{Float64, Int64} ``` and then ```julia buf = get!(() -> Any[], cachevars, T) ``` fails. This is (very) likely to occur with JSML, which appears to type things with `Float64`
1 parent 3a0784a commit 225fb55

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/systems/nonlinear/nonlinearsystem.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -712,6 +712,9 @@ function SciMLBase.SCCNonlinearProblem{iip}(sys::NonlinearSystem, u0map,
712712
k = unwrap(k)
713713
v = unwrap(v)
714714
T = symtype(k)
715+
while T isa Union
716+
T = promote_type(T.a, T.b)
717+
end
715718
buf = get!(() -> Any[], cachevars, T)
716719
push!(buf, v)
717720
buf = get!(() -> Any[], cacheexprs, T)

0 commit comments

Comments
 (0)