If you haven’t seen it already you probably want to read Successful Static Compilation of Julia Code for use in Production.
This particular problem isn’t discussed there. In general the best way to debug these kinds of issues is to try to simplify the code as much as possible until the problem goes away. @code_llvm
(or the function form) is helpful to spot when problematic calls appear.
For this code you can eliminate almost everything without getting rid of apply_generic
, until you realize that
julia> unsafe_trunc(1 + 2im)
ERROR: MethodError: no method matching unsafe_trunc(::Complex{Int64})
So well, the problem is that the code won’t run and needs to do dynamic things to tell you that. In other words, first verify that the code works before you try to debug static compilation failures.