fn negate(x: u32) u32 {
return -x;
}
This is currently safety-checked undefined behaviour, however, this misstake can already be catched
at compile time.
Another option is to make -unsigned return a signed type of higher bitness, so
fn negate(x: u32) i33 {
return -x;
}
would be valid.
Compiler error makes more sense IMO. If you want to change signed <-> unsigned, you should have to use an explicit cast.
Related: #1770
Closed by #5654
Most helpful comment
Compiler error makes more sense IMO. If you want to change signed <-> unsigned, you should have to use an explicit cast.