LYR-SEM0204
a comparison of an unsigned value with 0 that cannot fail
An unsigned value compared with the literal 0 in a way that is always true (n >= 0) or always false (n < 0).
Explanation
An unsigned value is never below 0, so the comparison decides nothing — the code that depends on it either always or never runs, which is rarely what the test was written for. Often the value was meant to be signed.
Take the comparison out, or compare what was meant: n > 0, or a signed type.
Wrong
fn main(): void {
let n: uint = 3;
if (n >= 0) {
let _ = n;
}
}
Right
fn main(): void {
let n: uint = 3;
if (n > 0) {
let _ = n;
}
}