Home / Docs / Diagnostics
U3013: Effectful or fallible call nested inside an expression
Release v0.4.0
A capability operation, or a call of a function that uses capabilities or can fail, is nested inside another expression or an argument.
Why Una rejects it
One effect per line: a capability operation, or a call of a function that uses capabilities or can fail, is the whole expression of a statement, a let right-hand side or a final expression, optionally wrapped in attempt (spec/04 §4). It cannot be nested inside another expression or an argument.
This fixes the order of evaluation, gives every failure a handling site and makes every effect visible on its own line.
Example do lines are exempt (spec/08 §2 rule 5).
How to fix it
Bind the result with let first.
The repair at a glance
diff
module demo
capability Clock
op now() -> Int
pub later() -> Int
uses @clock: Clock[now]
=
- 1 + @clock.now()
+ let now = @clock.now()
+ 1 + nowFailing example
una
module demo
capability Clock
op now() -> Int
pub later() -> Int
uses @clock: Clock[now]
=
1 + @clock.now()Fixed example
una
module demo
capability Clock
op now() -> Int
pub later() -> Int
uses @clock: Clock[now]
=
let now = @clock.now()
1 + now