Home / Docs / Diagnostics
U2011: Statement value is not Unit
Release v0.4.0
A statement that is not the last line of its block runs for its effect, so its value must be Unit (spec/02 §6); a value of another type would be silently discarded. Bind the value with let, or remove the statement.
The repair at a glance
diff
module demo
pub twice(x: Int) -> Int
=
- x + x
- x
+ let doubled = x + x
+ doubledFailing example
una
module demo
pub twice(x: Int) -> Int
=
x + x
xFixed example
una
module demo
pub twice(x: Int) -> Int
=
let doubled = x + x
doubled