f is a function that has quite a few methods and I use it somewhere deep in the call stack. I have two very similar methods, g, in one of them the return type of f is always inferred correctly for all x, and in the other one the return type of f is Any. Something like:
function g(x, y, z)
fx = f(x) # inferred as ::Any
h(fx, y, z)
function g(x, y)
fx = f(x) # inferred correctly
What are the criteria for julia to give up on type inference?
I probably wouldn’t even have notice this, because it is not in a performance sensitive part of the code but the issue was that there were only h(fx::SomeAbstractType, ...) methods which caused the compiler to assume that h would never be called and the program crashed with “Reached the unreachable” errors.
This could easily be fixed by adding f(x)::SomeAbstractType but finding the issue caused me a lot of headache.
I finally found the issue with Cthulhu.jl, it saved me from madness.