E0016
ErrorSafe fix
let in front of a field
ErrorSafe fixA field is written name: Type, or mut name: Type when it can change. It takes no let.
Why
let declares a binding in a block. A field belongs to the class, and mut alone says whether it can change (ADR 0011).
Broken
class Point {
let x: i64
y: i64
}
fn main() {
let p = Point(x: 1, y: 2)
print(p.x + p.y)
}
What sisu says
error[E0016]: a field takes no `let` --> E0016.sisu:2:5 | 2 | let x: i64 | ^^^ | help: remove the `let` | 2 - let x: i64 2 + x: i64 | sisu: 1 error sisu: for more on a code, run `sisu explain <code>`: E0016
Fixed
class Point {
x: i64
y: i64
}
fn main() {
let p = Point(x: 1, y: 2)
print(p.x + p.y)
}
Sisu