Sisu
E0065

Constructor argument without a label

ErrorSafe fix

Built from the repository at commit a8614dc.

Each argument of a constructor is labeled with the field it sets: Point(x: 1). A variant whose payload is labeled is built the same way: Shape.Rect(w: 2, h: 3). A variant with an unlabeled payload, such as Num(i64), takes its arguments without labels; a label there is E0055.

Why

The label says which field gets which value, so a constructor reads the same however many fields its class or variant has, and swapping two values of one type cannot go unnoticed.

Broken

class Point {
    x: i64
}

fn main() {
    let p = Point(1)
    print(p.x)
}

What sisu says

error[E0065]: this argument needs a label
 --> E0065.sisu:6:19
  |
6 |     let p = Point(1)
  |                   ^
  |
help: label it with its field
  |
6 |     let p = Point(x: 1)
  |                   ++

sisu: 1 error
sisu: for more on a code, run `sisu explain <code>`: E0065

Fixed

class Point {
    x: i64
}

fn main() {
    let p = Point(x: 1)
    print(p.x)
}