---
title: "U3001: Capability not in scope"
url: https://una-lang.org/en/docs/errors/U3001/
release: v0.4.0
source: https://github.com/una-lang/una/blob/v0.4.0/crates/una-explain/explain/U3001.md
---

# U3001: Capability not in scope

The code refers to a capability that no binding in scope holds.

## Why Una rejects it

A capability operation `@c.op(...)` acts through the binding `@c` of the current capability context (`spec/05 §1, §3`):

- a `uses` clause of the header;
- a `with` binding of the statement;
- a `given` line of an example;
- the `uses` of the function type a lambda is written for.

U3001 reports a reference that no binding in scope holds. It also reports:

- a call whose callee needs `@x: C[ops]` when the caller holds no `@x`, or holds a capability other than `C` under that name (`spec/05 §4`);
- a `do` line that needs a capability no `given` line binds (`spec/08 §2`);
- a private function whose inferred reference cannot be given one capability, because no caller binds it or callers bind it to different capabilities (`spec/04 §5`).

## How to fix it

- Bind it with `with` from a binding in scope, or install a handler with `given`. These keep the code's authority.
- Declaring the capability with `uses` widens the header, and its repair says so (ADR 0097).

## The repair at a glance

```diff
  module demo

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

  pub note(line: Text) -> Unit
-   uses @journal: Log[write]
+   uses @log: Log[write]
  =
    @log.write(line)
```

## Failing example

```una
module demo

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

pub note(line: Text) -> Unit
  uses @journal: Log[write]
=
  @log.write(line)
```

## Fixed example

```una
module demo

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

pub note(line: Text) -> Unit
  uses @log: Log[write]
=
  @log.write(line)
```
