---
title: "U2023: A binding declared outside a `together` branch assigned, or passed as `edit` or `take`, inside it"
url: https://una-lang.org/en/docs/errors/U2023/
release: v0.4.0
source: https://github.com/una-lang/una/blob/v0.4.0/crates/una-explain/explain/U2023.md
---

# U2023: A binding declared outside a `together` branch assigned, or passed as `edit` or `take`, inside it

The branches of a `together` block, and the body of a `together for`, run as concurrent tasks (`spec/19`). A task captures the values of the bindings declared before it, as a lambda does, and cannot change them: inside a task, a binding declared outside it cannot be assigned, passed as `edit`, or passed as `take` (`spec/19 §2` rule 3). Return the new value from the branch instead, and use it after the block, where every task has finished.

## The repair at a glance

`src/demo.una`

```diff
  module demo

  pub both(a: Int, b: Int) -> Int
  =
    let edit total = 0
    together
-     let x = bump(edit total, by: a)
+     let x = a * 2
      let y = b + 1
-   total + x + y
-
- bump(edit n: Int, by: Int) -> Int
- =
-   n = n + by
-   n
+   total = total + x
+   total + y
```

## Failing example

`una.toml`

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

`src/demo.una`

```una
module demo

pub both(a: Int, b: Int) -> Int
=
  let edit total = 0
  together
    let x = bump(edit total, by: a)
    let y = b + 1
  total + x + y

bump(edit n: Int, by: Int) -> Int
=
  n = n + by
  n
```

## Fixed example

`una.toml`

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

`src/demo.una`

```una
module demo

pub both(a: Int, b: Int) -> Int
=
  let edit total = 0
  together
    let x = a * 2
    let y = b + 1
  total = total + x
  total + y
```
