StaticCompiler - how to handle integer division error?

I found a solution. Define a new function

function myrem(a, b)
    b==0 ? 0 : a%b
end

Then replace any a%b in the code by myrem(a, b). This allows the compiler to know that I never call % when b is zero, and I’m able to use StaticCompiler.compile_executable, without getting errors.

Edit: corrected operator name from mod to rem.

3 Likes