E0043
Expression without a value
ErrorAn expression whose value is used must have one. A call of a function that returns nothing has none, and neither has an if without an else. An expression that never finishes, such as an if whose branches all return, has none either. Nor has a bare break in a loop whose other breaks give it a value.
Why
A let, an argument, an operand or a condition needs a value to work with. Nothing is left to bind when the expression returns nothing, or never returns.
Broken
fn greet() {
print(1)
}
fn main() {
let x = greet()
print(x)
}
What sisu says
error[E0043]: expression has no value --> E0043.sisu:6:13 | 6 | let x = greet() | ^^^^^^^ sisu: 1 error sisu: for more on a code, run `sisu explain <code>`: E0043
Fixed
fn one() -> i64 {
1
}
fn main() {
let x = one()
print(x)
}
Related
- W0001: a statement that follows one that never finishes.
Sisu