---
title: "U2018: An `edit` argument together with another use of its binding in the same call"
url: https://una-lang.org/en/docs/errors/U2018/
release: v0.4.0
source: https://github.com/una-lang/una/blob/v0.4.0/crates/una-explain/explain/U2018.md
---

# U2018: An `edit` argument together with another use of its binding in the same call

A call that passes `edit p` may not use the root binding of `p` anywhere else: not in another argument, not as another `edit` or `take` argument, and not through a disjoint field, so `f(edit r.x, y: r.y)` is U2018 too (`spec/17 §3` rule 4). The callee changes the place while the other argument is read, and exclusivity keeps the order of the two from mattering. Bind the other value with `let` before the call.

## The repair at a glance

`src/demo.una`

```diff
  module demo

  pub kind Point
    x: Int
    y: Int

  pub shift(edit p: Point, by: Int) -> Unit
  =
    p.x = p.x + by

  pub step() -> Point
  =
    let edit p = Point(x: 1, y: 2)
-   shift(edit p, by: p.y)
+   let dy = p.y
+   shift(edit p, by: dy)
    p
```

## Failing example

`una.toml`

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

`src/demo.una`

```una
module demo

pub kind Point
  x: Int
  y: Int

pub shift(edit p: Point, by: Int) -> Unit
=
  p.x = p.x + by

pub step() -> Point
=
  let edit p = Point(x: 1, y: 2)
  shift(edit p, by: p.y)
  p
```

## Fixed example

`una.toml`

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

`src/demo.una`

```una
module demo

pub kind Point
  x: Int
  y: Int

pub shift(edit p: Point, by: Int) -> Unit
=
  p.x = p.x + by

pub step() -> Point
=
  let edit p = Point(x: 1, y: 2)
  let dy = p.y
  shift(edit p, by: dy)
  p
```
