Mixed-type integer comparison ============================= This is tricky: int8 i = ... uint64 j = ... int32 k = ... if i + j < k There are two problems here: 1. Mixing range (signedness and type) in the operands of the comparison 2. What is the target type of the operands? I.e. how to compute `i+j`? Solutions to the mixed-range problem ------------------------------------ 1a) Just check whether the operands are mutually out of range for some values, leading to an always-true or always-false comparison. E.g. a negative value is less than any value of an unsigned type. 1b) Disallow mixed-signedness comparison. Solutions to the target type problem ------------------------------------ Point 2 is trickier to solve. 2a) Use algebra to determine whether the comparison returns true. But this can get really tricky, for example if multiplication appears on both sides of the expression, leading to possibly very large values. Or the expressions might be impossible to simplify enough to compute algebraically. 2b) Require either side to have a clear type (this is what LRL did). 2c) Require the programmer to specify a target type. Syntax examples: i + j <(uint64) k i + j (uint64)< k i + j uint64 < k (i + j) as uint64 < k as uint64 uint64_less (i + j) k 2d) Promote to largest type? Promote to signed if mixed, and report a compiler error if too large for signed type. Maybe promote mixed-signed integers <= 32 bits to a larger type, e.g. mixed int32/uint32 to int64. 2e) Promote to *smallest* type, and report a compiler error if not within range for that type.