---
title: "U3028: A function that says `diverges`, used as a value"
url: https://una-lang.org/en/docs/errors/U3028/
release: v0.4.0
source: https://github.com/una-lang/una/blob/v0.4.0/crates/una-explain/explain/U3028.md
---

# U3028: A function that says `diverges`, used as a value

A function that says `diverges` may run forever (`spec/26 §5`, ADR 0116 rule 8). Bound as a value, it could be called later through a function type that carries no `diverges`, from code that does not say it may run forever, so it is not a value anywhere: name it only as a callee, in a function that says `diverges`. The error is at the name.

## The repair at a glance

`src/demo.una`

```diff
  module demo

  spin() -> Int
    diverges
  =
    let edit n = 0
    for ever
      stop when n > 9
      n = n + 1
    n

  pub held() -> Int
+   diverges
  =
-   let f = spin
-   1
+   spin()
```

## Failing example

`ita.una`

```una
ita demo
  version 0.1.0
  edition 0.4
```

`ita.lock`

```una
lock 1

solver
  encoding "una-smt-1"
  name "z3"
  version "5.1.0"
  logic "QF_UFLIA"
  steps 5000000
  seed 0
```

`src/demo.una`

```una
module demo

spin() -> Int
  diverges
=
  let edit n = 0
  for ever
    stop when n > 9
    n = n + 1
  n

pub held() -> Int
=
  let f = spin
  1
```

## Fixed example

`ita.una`

```una
ita demo
  version 0.1.0
  edition 0.4
```

`ita.lock`

```una
lock 1

solver
  encoding "una-smt-1"
  name "z3"
  version "5.1.0"
  logic "QF_UFLIA"
  steps 5000000
  seed 0
```

`src/demo.una`

```una
module demo

spin() -> Int
  diverges
=
  let edit n = 0
  for ever
    stop when n > 9
    n = n + 1
  n

pub held() -> Int
  diverges
=
  spin()
```
