E0047
Comparison of values of different types
ErrorBoth sides of a comparison have one type. A T may stand beside a T?, and nothing else is compared across types. Equality and ordering comparisons between a u8 and an i64, or between a char and an integer, report E0032 instead. So does an ordering comparison of a string or a char with another type.
Why
A comparison of an i64 with a bool, or of two different classes, can never be true. Sisu reports it instead of answering false.
Broken
fn main() {
print(1 == true)
}
What sisu says
error[E0047]: cannot compare `i64` with `bool` --> E0047.sisu:2:11 | 2 | print(1 == true) | ^^^^^^^^^ sisu: 1 error sisu: for more on a code, run `sisu explain <code>`: E0047
Fixed
fn main() {
print(1 == 1)
}
Related
- E0032: a value of the wrong type.
Sisu