Home / Docs / Diagnostics
U2019: Assignment to a binding that is not editable
Release v0.4.0
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
module demo
pub total(xs: List[Int]) -> Int
=
- let sum = 0
+ let edit sum = 0
sum = xs.sum
sumFailing example
una.toml
[package]
name = "demo"
version = "0.1.0"
edition = "0.2"src/demo.una
module demo
pub total(xs: List[Int]) -> Int
=
let sum = 0
sum = xs.sum
sumFixed example
una.toml
[package]
name = "demo"
version = "0.1.0"
edition = "0.2"src/demo.una
module demo
pub total(xs: List[Int]) -> Int
=
let edit sum = 0
sum = xs.sum
sum