Sisu
E0049

?. on a value that is not optional

ErrorSafe fix

Built from the repository at commit a8614dc.

?. reads a field or calls a method of an optional, and is None when the optional is. Its receiver must be an optional.

Why

A receiver that is not optional is never None, so a plain . says the same, and its result is not made optional.

Broken

class Point {
    x: i64
}

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

What sisu says

error[E0049]: `p` is not optional
 --> E0049.sisu:7:13
  |
7 |     let x = p?.x
  |             ^
  |
help: replace `?.` with `.`
  |
7 -     let x = p?.x
7 +     let x = p.x
  |

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

Fixed

class Point {
    x: i64
}

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