Home / Docs / Diagnostics

U3002: Operation not permitted by capability type

Release v0.4.0

The code uses an operation that the capability type of the binding in scope does not permit.

Why Una rejects it

A binding @x: C[ops] permits only the operations listed in brackets; without brackets it permits all of them (spec/05 §3). U3002 reports:

How to fix it

The repair at a glance

diff
  module demo

  capability Log
    op write(line: Text) -> Unit
    op flush() -> Unit

  pub finish() -> Unit
-   uses @log: Log[write]
+   uses @log: Log[write, flush]
  =
    @log.flush()

Failing example

una
module demo

capability Log
  op write(line: Text) -> Unit
  op flush() -> Unit

pub finish() -> Unit
  uses @log: Log[write]
=
  @log.flush()

Fixed example

una
module demo

capability Log
  op write(line: Text) -> Unit
  op flush() -> Unit

pub finish() -> Unit
  uses @log: Log[write, flush]
=
  @log.flush()