---
title: "U3004: Capability used in a pure function"
url: https://una-lang.org/en/docs/errors/U3004/
release: v0.4.0
source: https://github.com/una-lang/una/blob/v0.4.0/crates/una-explain/explain/U3004.md
---

# U3004: Capability used in a pure function

A pure function uses a capability.

## Why Una rejects it

A function without `uses` is pure: it cannot contain any `@` (`spec/04 §2` rule 4). This holds for:

- a public function, which declares every `uses` explicitly;
- a lambda whose expected function type has no `uses` (`spec/04 §6`), such as the argument of `map`.

A private function without `uses` is not pure: its `uses` are inferred (`spec/04 §5`).

## How to fix it

Declare the capability in the header, or in the function type the lambda is written for. The repair is marked as a widening of authority (ADR 0097).

## The repair at a glance

```diff
  module demo

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

- pub report() -> Unit = @log.write("done")
+ pub report() -> Unit
+   uses @log: Log[write]
+ =
+   @log.write("done")
```

## Failing example

```una
module demo

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

pub report() -> Unit = @log.write("done")
```

## Fixed example

```una
module demo

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

pub report() -> Unit
  uses @log: Log[write]
=
  @log.write("done")
```
