---
title: "U3026: `attempt` of a call that cannot fail"
url: https://una-lang.org/en/docs/errors/U3026/
release: v0.4.0
source: https://github.com/una-lang/una/blob/v0.4.0/crates/una-explain/explain/U3026.md
---

# U3026: `attempt` of a call that cannot fail

The operand of an `attempt` is a call that cannot fail.

## Why Una rejects it

In edition 0.3, the operand of `attempt` must be a call that can fail (`spec/06 §5`, ADR 0100). `attempt` of a call that cannot fail gives a `Result` whose `Err` arm is never taken, with an error type that the program never produces.

The rule waits while the package has an error that can hide a failure, as U3025 does.

Editions 0.1 and 0.2 accept the `attempt`.

## How to fix it

Remove `attempt` and use the value of the call directly. Then unwrap each use of the `Result`:

- a `when ... is Ok(v)` becomes the value `v`;
- its `is Err` arm goes;
- a declared `Result[T, E]` becomes `T`.

The repair describes this change and carries no edit, since the uses must change with it.

## The repair at a glance

`src/demo.una`

```diff
  module demo

  double(n: Int) -> Int = n * 2

- pub tried(n: Int) -> Result[Int, Text] = attempt double(n)
+ pub tried(n: Int) -> Int = double(n)
```

## Failing example

`una.toml`

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

`src/demo.una`

```una
module demo

double(n: Int) -> Int = n * 2

pub tried(n: Int) -> Result[Int, Text] = attempt double(n)
```

## Fixed example

`una.toml`

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

`src/demo.una`

```una
module demo

double(n: Int) -> Int = n * 2

pub tried(n: Int) -> Int = double(n)
```
