Type instability when solving ODEProblem

Hello, in the following I show a minimal working example of the problem. I want to implement a type stable function that solves an ODE. But I figured out that the solve function returns Any type. This is the minimal code:

function prova(A, b, tspan; alg=Tsit5())
    prob = ODEProblem{true}(prova_func, b, tspan, (L=A,))
    sol = solve(prob, alg)
    return prova(sol)
end

function prova(sol)
    return sol.u
end

prova_func(du, u, p, t) = mul!(du, p.L, u)

A = rand(5,5)
b = rand(5)
tspan = (0, 1)
res = prova(A, b, tspan)

but when I use Cthulhu to discover type instabilities, I see that the function solve returns Any. After that, it is impossible for julia to identify the type of the outcome of the solution.

How to solve it?

simplify the problem a bit by making tspan floats. If not remake is required then is it fine? Our inference tests do pass so it should be the case.

1 Like

Thanks, making tspan float solved the problem.

Is it a good idea to use prova(sol) as a function barrier? Is there any other way? Sorry, I am a newbie.

update: I have found ODEProblem{true, SciMLBase.AutoSpecialize}, I am working on it to know what’s going on. Thanks