I am writing a fairly large project and I am trying to be very careful about type stability by checking all functions I write with @code_warntype
and the JET tests. Doing these tests, I found something very strange that I cannot understand. Essentially, the result of @code_warntype
on a function with exactly the same input depends on the order of compilation.
More specifically, say I am testing function one
; I know that this function depends on another function, two
. If, in a fresh Julia session, I check @code_warntype one(arg1, arg2)
, I get a red line telling the result of this call is Any
.
If, instead, on another fresh Julia session I first force the compilation of two
by calling @code_warntype two(arg3, arg4)
and then check @code_wantype one(arg1, arg2)
, I do not get any red line: the result of one
is Float64
!
Sorry to be very generic here, but the project is quite large and finding a minimal working example is non-trivial.
Caveat: in the project I am using generated functions. Could that be at the origin of the issue I am finding?