Home / Docs / Diagnostics
U3028: A function that says diverges, used as a value
Release v0.4.0
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
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
ita demo
version 0.1.0
edition 0.4ita.lock
lock 1
solver
encoding "una-smt-1"
name "z3"
version "5.1.0"
logic "QF_UFLIA"
steps 5000000
seed 0src/demo.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
1Fixed example
ita.una
ita demo
version 0.1.0
edition 0.4ita.lock
lock 1
solver
encoding "una-smt-1"
name "z3"
version "5.1.0"
logic "QF_UFLIA"
steps 5000000
seed 0src/demo.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()