---
title: "U2034: `stop` or `skip` outside a loop body, or across a task boundary"
url: https://una-lang.org/en/docs/errors/U2034/
release: v0.4.0
source: https://github.com/una-lang/una/blob/v0.4.0/crates/una-explain/explain/U2034.md
---

# U2034: `stop` or `skip` outside a loop body, or across a task boundary

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 of `together`, 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 `for` loop inside the task.

## The repair at a glance

`src/demo.una`

```diff
  module demo

  pub doubled(xs: List[Int]) -> List[Int]
  =
    together for x in xs
      if x < 0
-       skip
-     x + x
+       0
+     else
+       x + x
```

## 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

pub doubled(xs: List[Int]) -> List[Int]
=
  together for x in xs
    if x < 0
      skip
    x + x
```

## 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

pub doubled(xs: List[Int]) -> List[Int]
=
  together for x in xs
    if x < 0
      0
    else
      x + x
```
