Sisu
E0066

Constructor that names its fields out of order

Error

Built from the repository at commit a8614dc.

A constructor names the fields of its class, or the labeled payload of its variant, in the order they are declared.

Why

One order for every constructor of a class or variant makes the constructors easy to compare, and makes the order in which the arguments run the order of the fields.

Broken

class Point {
    x: i64
    y: i64
}

fn main() {
    let p = Point(y: 2, x: 1)
    print(p.x + p.y)
}

What sisu says

error[E0066]: expected field `x` here, found `y`
 --> E0066.sisu:7:19
  |
7 |     let p = Point(y: 2, x: 1)
  |                   ^
  |
  = help: name the fields in declaration order: `x`, `y`

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

Fixed

class Point {
    x: i64
    y: i64
}

fn main() {
    let p = Point(x: 1, y: 2)
    print(p.x + p.y)
}

Related

  • E0056: a constructor without every field.