Home / Docs / Diagnostics
U3003: Effects exceed declared uses
Release v0.4.0
The effects of a body exceed the uses that its header declares.
Why Una rejects it
The uses clauses of a header bound every effect of the body, including the effects of the functions it calls (spec/04 §2, spec/10 §8). A public function declares every uses explicitly (spec/04 §5), so a public function without uses is pure.
- U3003 reports a call in it of a function, or an installation of a handler, that uses capabilities.
- It also reports a function passed as an argument whose
usesthe expected function type does not allow (spec/10 §2).
How to fix it
- Call a pure function, which keeps the function pure.
- Or declare the
usesthat the callee needs, which widens the header. That repair is marked as a widening (ADR 0097).
The repair at a glance
diff
module demo
capability Log
op write(line: Text) -> Unit
pub note(line: Text) -> Unit
uses @log: Log[write]
=
@log.write(line)
- pub report() -> Unit = note("done")
+ pub report() -> Unit
+ uses @log: Log[write]
+ =
+ note("done")Failing example
una
module demo
capability Log
op write(line: Text) -> Unit
pub note(line: Text) -> Unit
uses @log: Log[write]
=
@log.write(line)
pub report() -> Unit = note("done")Fixed example
una
module demo
capability Log
op write(line: Text) -> Unit
pub note(line: Text) -> Unit
uses @log: Log[write]
=
@log.write(line)
pub report() -> Unit
uses @log: Log[write]
=
note("done")