---
title: "U3022: Labeled operation passed to code that reads it lower"
url: https://una-lang.org/en/docs/errors/U3022/
release: v0.4.0
source: https://github.com/una-lang/una/blob/v0.4.0/crates/una-explain/explain/U3022.md
---

# U3022: Labeled operation passed to code that reads it lower

A call passes a binding whose operation gives more than the label at which the callee reads its answers.

## Why Una rejects it

In edition `0.3`, an operation listed in a header's `uses` brackets can carry `gives` and a label: `uses @service_files: Files[owner gives internal[Service]]` says that what `owner` answers through this binding, the value and whether it failed, belongs to the principal `Service` (ADR 0094, `spec/05 §3`). The answer then carries the label, and the flow rules of `spec/07` keep it from reaching anyone below it.

A binding flows to a callee by name or with `with`, and its labels go with it. The callee reads the operation's answers at the label its own header writes, `public` when it writes none. A private function without `uses` clauses infers its labels instead, the join of what its callers pass, so the labeled binding reaches it and its body reads the answers at that label.

A binding whose operation gives more than that is refused at the call with U3022: the callee would read the answer below its label.

## How to fix it

The repairs never lower a label:

- Pass another binding whose operation gives at most what the callee reads, when the caller holds one.
- Or raise the `gives` in the callee's header, which then changes what its callers see.

## The repair at a glance

`src/demo.una`

```diff
  module demo

  pub capability Files
    op owner(file: Text) -> Text

- owner_seen(file: Text) -> Text
-   uses @files: Files[owner]
+ owner_seen(file: Text) -> internal[Service] Text
+   uses @files: Files[owner gives internal[Service]]
  =
    @files.owner(file)

  pub refusal(file: Text) -> internal[Service] Text
    uses @service_files: Files[owner gives internal[Service]]
  =
    let seen = owner_seen(file) with @files = @service_files
    seen
```

## Failing example

`una.toml`

```toml
[package]
name = "demo"
version = "0.1.0"
edition = "0.3"

[labels]
categories = ["Service"]
```

`src/demo.una`

```una
module demo

pub capability Files
  op owner(file: Text) -> Text

owner_seen(file: Text) -> Text
  uses @files: Files[owner]
=
  @files.owner(file)

pub refusal(file: Text) -> internal[Service] Text
  uses @service_files: Files[owner gives internal[Service]]
=
  let seen = owner_seen(file) with @files = @service_files
  seen
```

## Fixed example

`una.toml`

```toml
[package]
name = "demo"
version = "0.1.0"
edition = "0.3"

[labels]
categories = ["Service"]
```

`src/demo.una`

```una
module demo

pub capability Files
  op owner(file: Text) -> Text

owner_seen(file: Text) -> internal[Service] Text
  uses @files: Files[owner gives internal[Service]]
=
  @files.owner(file)

pub refusal(file: Text) -> internal[Service] Text
  uses @service_files: Files[owner gives internal[Service]]
=
  let seen = owner_seen(file) with @files = @service_files
  seen
```
