Home / Docs / Diagnostics
U2034: stop or skip outside a loop body, or across a task boundary
Release v0.4.0
A stop or skip is outside a loop body, or across a task boundary from its loop.
Why Una rejects it
In edition 0.4, stop ends the innermost for loop around it, stop when c does so when c holds, and skip ends the current iteration and goes on to the next (spec/26 §3, ADR 0116 rule 6). Each belongs to the body of its innermost loop. It is an error:
- outside any loop body;
- when the innermost loop lies outside the nearest enclosing task: the body of a
together for, or a branch oftogether, is not a loop for them, so they cannot end an iteration of a loop that runs the task.
A loop inside the task is a loop for them.
How to fix it
To end a task's work early:
- Give its block a value with
if. - Or put a
forloop inside the task.
The repair at a glance
src/demo.una
module demo
pub doubled(xs: List[Int]) -> List[Int]
=
together for x in xs
if x < 0
- skip
- x + x
+ 0
+ else
+ x + xFailing 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
pub doubled(xs: List[Int]) -> List[Int]
=
together for x in xs
if x < 0
skip
x + xFixed 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
pub doubled(xs: List[Int]) -> List[Int]
=
together for x in xs
if x < 0
0
else
x + x