Sisu
E0056

Constructor without every field

Error

Built from the repository at commit a8614dc.

A constructor names every field of its class, in declaration order: Point(x: 1, y: 2). A variant with a labeled payload is built the same way: Shape.Rect(w: 2, h: 3).

Why

Sisu has no default values for fields. Every field of a new object or enum value needs a value, so a constructor that leaves one out cannot build it.

Broken

class Point {
    x: i64
    y: i64
}

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

What sisu says

error[E0056]: missing field `y`
 --> E0056.sisu:7:13
  |
7 |     let p = Point(x: 1)
  |             ^^^^^^^^^^^
  |
  = help: name the fields in declaration order: `x`, `y`

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

Fixed

class Point {
    x: i64
    y: i64
}

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

Related

  • E0064: a constructor with more arguments than the class or variant has fields.
  • E0066: a constructor that names its fields out of order.