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.

How to fix it

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")