Sisu
E0019

mut parameter

Error

Built from the repository at commit a8614dc.

A parameter cannot be mut. It keeps the value it was passed.

Why

A parameter that changed would look like a change to the caller's value, which it never is (ADR 0011). Copy the parameter into a let mut variable and change the copy.

Broken

fn add_one(mut n: i64) -> i64 {
    n += 1
    n
}

fn main() {
    print(add_one(1))
}

What sisu says

error[E0019]: a parameter cannot be `mut`
 --> E0019.sisu:1:12
  |
1 | fn add_one(mut n: i64) -> i64 {
  |            ^^^
  |
  = help: copy it into a variable: `let mut n = n`

sisu: 1 error
sisu: for more on a code, run `sisu explain <code>`: E0019

Fixed

fn add_one(n: i64) -> i64 {
    let mut total = n
    total += 1
    total
}

fn main() {
    print(add_one(1))
}