---
title: "U2019: Assignment to a binding that is not editable"
url: https://una-lang.org/en/docs/errors/U2019/
release: v0.4.0
source: https://github.com/una-lang/una/blob/v0.4.0/crates/una-explain/explain/U2019.md
---

# U2019: Assignment to a binding that is not editable

The code assigns to a binding that is not editable.

## Why Una rejects it

Only a binding declared `let edit`, or a parameter declared `edit`, can be assigned, have a field assigned, or be passed as `edit` (`spec/17 §2`). A plain `let` and a plain or `take` parameter are fixed.

A lambda captures the value a binding has when the lambda is created. So inside a lambda a captured binding is not editable either (`spec/17 §5` rule 4).

## How to fix it

- Declare the binding `let edit`.
- Or bind the new value to a new name.

## The repair at a glance

`src/demo.una`

```diff
  module demo

  pub total(xs: List[Int]) -> Int
  =
-   let sum = 0
+   let edit sum = 0
    sum = xs.sum
    sum
```

## Failing example

`una.toml`

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

`src/demo.una`

```una
module demo

pub total(xs: List[Int]) -> Int
=
  let sum = 0
  sum = xs.sum
  sum
```

## Fixed example

`una.toml`

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

`src/demo.una`

```una
module demo

pub total(xs: List[Int]) -> Int
=
  let edit sum = 0
  sum = xs.sum
  sum
```
