$ crystal -v
Crystal 0.31.0 [8d4715a59] (2019-09-23)
LLVM: 8.0.0
Default target: x86_64-unknown-linux-gnu
$ echo 'puts (Int64::MIN % -1_i64)' | crystal eval
Program received and didn't handle signal FPE (8)
Hah OK, this is a great catch.
I'm not sure, did people think that it's not possible to overflow with % or that this one case is not worth the error checking?
I think % already does some safety checks, like raising if the divisor is zero, so it would be fine to raise overflow on this case.
Int#remainder have the same issue.
Int#check_div_argument has these checks but it is used in neither remainder nor %.
There is one thing that confounds me though: Why does it overflow in the first place? It is certainly not the answer that is too big - in this case it should be 0.
Probably because division would overflow