Sisu
E0120

Variant or method used as the other

Error

Built from the repository at commit a8614dc.

An enum's variants are built through the enum, Expr.Num(1), and its methods are called on a value, e.eval(). A variant called on a value, or a method named through the enum, is an error.

Why

Sisu has one way to build a variant and one way to call a method, so Expr.eval never reads as a function value and e.Num(1) never reads as a method. The error names the form that works; there is no fix, since the value to call the method on is yours to choose.

Broken

enum Expr {
    Num(i64)
}

fn make(e: Expr) -> Expr {
    e.Num(1)
}

fn main() {
    match make(Expr.Num(0)) {
        Num(n) => print(n)
    }
}

What sisu says

error[E0120]: `Num` is a variant; build it with `Expr.Num`
 --> E0120.sisu:6:7
  |
6 |     e.Num(1)
  |       ^^^

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

Fixed

enum Expr {
    Num(i64)
}

fn make(e: Expr) -> Expr {
    match e {
        Num(n) => Expr.Num(n + 1)
    }
}

fn main() {
    match make(Expr.Num(0)) {
        Num(n) => print(n)
    }
}