Sisu
E0027

Class that can never be constructed

ErrorUnsafe fix

Built from the repository at commit a8614dc.

A class cannot have a field that needs an object of the class itself, directly or through other classes, unless some field on the way is optional. No first object of such a class could exist.

An enum has the same error when every one of its variants needs a value of the enum itself, directly or through other classes and enums: "no value of Bad can be built", with the chain of fields that needs a Bad. One variant that needs no such value is enough: an enum List with the variants Nil and Cons(i64, List) can be built from List.Nil.

Why

To build a Node, Sisu needs the Node that its field next holds, and to build that one it needs another. An optional field, written Node?, can hold None and ends the chain.

Broken

class Node {
    next: Node
}

fn main() {
    print(1)
}

What sisu says

error[E0027]: `Node` can never be constructed: field `next` needs a value of type `Node`
 --> E0027.sisu:2:5
  |
2 |     next: Node
  |     ^^^^
  |
help: if the field can be absent, make it optional: `Node?`
  |
2 |     next: Node?
  |               +

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

Fixed

class Node {
    next: Node?
}

fn main() {
    let n = Node(next: None)
    print(n.next == None)
}