Hm, I’ve found one more potential source of confusion here. Integer literals without suffixes are polymorphic. Their type is inferred from use, if it is unambiguous, and defaults to i32 (am I correct here?) if it is not constrained.
That is, in the following code
let c = 92;
The c can have any integral type, and you need to see usages of c to determine it’s precise type. In your first example,
let a = -2;
let b:u32 = 2;
let c = a / b;
all three variables are typed as u32 because of the explicit annotation for b.
So this
Is not always true. There is not enough information to say if these are signed or unsigned numbers. If the next line is, say, let d = c / 2u32 then these are signed 32 numbers. But if the next line is let d = c * 92i64 these are signed 64 bit numbers.
This looks complicated, but in practice is rarely a problem. Oftentimes you have an explicitly typed variable in the expression, and you can always use suffixes. Please not also that the issue is not with type of an arithmetic expression, but with the type of a literal.