Skip to content

`addIntC#`'s documentation lacks precision on the return type

Currently, the documentation for addIntC# tells us

Add signed integers reporting overflow. First member of result is the sum truncated to an Int#; second member is zero if the true sum fits in an Int#, nonzero if overflow occurred (the sum is either too large or too small to fit in an Int#).

Unfortunately, nonzero is far from being enough for consumers of this API. Should we expect it to be 1 all the time? 1 in most cases? Would it be an implementation error for the function to return something other than 1?
In particular, given that isTrue# seems to behave unpredictably on arguments that are non-zero but >1, is it safe to useisTrue# on the result?

Note: This would also be the opportunity to clarify the behaviour of isTrue# in presence of a well-typed, yet undesirable argument.

cc @michaelpj

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information