E0081
Block that stands alone as a statement
ErrorA { ... } block is an expression. It belongs where a value does, as in let x = { ... }. A statement cannot start with {.
Why
A block's value is its last expression. As a statement that value would go nowhere, and a scope with no value has no use of its own. Put the block where its value is wanted.
Broken
fn main() {
{
let a = 1
print(a + 2)
}
}
What sisu says
error[E0081]: a block cannot stand alone as a statement --> E0081.sisu:2:5 | 2 | { | ^ | = help: bind its value: `let x = { ... }` sisu: 1 error sisu: for more on a code, run `sisu explain <code>`: E0081
Fixed
fn main() {
let total = {
let a = 1
a + 2
}
print(total)
}
Related
- E0004:
{on a line of its own.
Sisu