---
title: "U3025: `if error` clause on an expression that cannot fail"
url: https://una-lang.org/en/docs/errors/U3025/
release: v0.4.0
source: https://github.com/una-lang/una/blob/v0.4.0/crates/una-explain/explain/U3025.md
---

# U3025: `if error` clause on an expression that cannot fail

An `if error` clause is on an expression that cannot fail.

## Why Una rejects it

In edition 0.3, an `if error` clause belongs only where the expression can fail (`spec/06 §3`, ADR 0100). A clause on an expression that cannot fail never runs:

- arithmetic;
- a call of a function without `fails`;
- an operation without `fails`;
- or anything wrapped in `attempt`, which already turns the failure into a value.

It also misleads the reader, and a dead `if error fail V` in a private function gives that function an error kind of its own, which every caller then has to handle.

The rule waits while the package has an error that can hide a failure: an error outside U3007, U3008 and U3009, or one inside the function that is called.

Editions 0.1 and 0.2 accept the clause.

## How to fix it

Remove the clause. `una fix` applies this repair.

## The repair at a glance

`src/demo.una`

```diff
  module demo

  kind LookupError = Missing | Unavailable

  pub next(n: Int) -> Int
    fails LookupError
  =
    let x = n + 1
-     if error fail Unavailable
    x
```

## Failing example

`una.toml`

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

`src/demo.una`

```una
module demo

kind LookupError = Missing | Unavailable

pub next(n: Int) -> Int
  fails LookupError
=
  let x = n + 1
    if error fail Unavailable
  x
```

## Fixed example

`una.toml`

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

`src/demo.una`

```una
module demo

kind LookupError = Missing | Unavailable

pub next(n: Int) -> Int
  fails LookupError
=
  let x = n + 1
  x
```
