LYR-SEM0059
an equality, null or membership test the type does not support
==/!= is applied to a type without Equatable or to an optional, == null to a value that can never be null, or in/!in to a container without Contains<T>.
Explanation
Equality on a user type comes from Equatable: a == b is a.equals(b). Membership comes from Contains<T>: x in xs is xs.contains(x). A type that does not conform has no such operator. Two optionals are not compared directly: narrow them first. == null is asked only of a ?T; a value of any other type, a bare type parameter included, is never null.
Declare the conformance (:: [Equatable] with fn equals), compare fields that have equality, or declare the value optional if it may be absent.
Wrong
struct Point {
x: int,
}
fn main(): void {
let p = Point { x = 1 };
let q = Point { x = 1 };
let _ = p == q;
}
Right
struct Point {
x: int,
}
fn main(): void {
let p = Point { x = 1 };
let q = Point { x = 1 };
let _ = p.x == q.x;
}