Open j-hui opened 3 years ago
Leaving a note here that overflow of fixed precision integers in Haskell is undefined. In fact, the specific behavior differ within the same platform/compiler implementation: https://rosettacode.org/wiki/Integer_overflow#Haskell.
Follow on from #32 --- I patched up the generated code to only use C's unsigned ints, for which we can rely on reliably wrapping around on overflow, but the matter of what happens with the Haskell-side interpreter is another matter. In particular, overflow for
Int
seems to be undefined no matter what. We're not encountering any failed test cases yet, but we should account for this at some point, with some bounds checks, or by converting all arithmetic to take place withInteger
and perform the wraparound ourselves.