---
title: "U0102: Clause out of order or repeated"
url: https://una-lang.org/en/docs/errors/U0102/
release: v0.4.0
source: https://github.com/una-lang/una/blob/v0.4.0/crates/una-explain/explain/U0102.md
---

# U0102: Clause out of order or repeated

U0102 reports a clause placed after a clause that must follow it, and a repeated `fails`, `derived from`, `accepts`, `if error` or `if none` clause.

## Why Una rejects it

- The clauses of a function header follow one canonical order: every `requires`, then every `ensures`, then every `uses`, then at most one `fails`, then at most one `derived from` (`spec/02 §3`).
- Capability operations follow the same idea: every `requires`, then every `ensures`, then at most one `fails`, then at most one `accepts` (`spec/02 §4`).
- The handling clauses of a statement come in the order `if error`, then `if none`, each at most once (`spec/06 §3`).

A fixed order lets people and tools find each part of a contract at a glance.

A `fails` or `derived from` clause is not repeated: a function or operation fails with a single error kind (ADR 0006), and one `derived from` lists all its requirements.

## The repair at a glance

```diff
  module demo

  pub double(x: Int) -> Int
-   ensures result == x * 2
    requires x >= 0
+   ensures result == x * 2
  =
    x * 2
```

## Failing example

```una
module demo

pub double(x: Int) -> Int
  ensures result == x * 2
  requires x >= 0
=
  x * 2
```

## Fixed example

```una
module demo

pub double(x: Int) -> Int
  requires x >= 0
  ensures result == x * 2
=
  x * 2
```
