---
title: "19.8 Common mistakes"
url: https://una-lang.org/en/learn/editions/common-mistakes/
release: v0.4.0
edition: "0.1, 0.2, 0.3, 0.4"
---

# 19.8 Common mistakes

The first two mistakes are changes to the edition `0.1` stock list of [section 19.1](https://una-lang.org/en/learn/editions/an-edition-is-part-of-the-package/#s19-1). The others are changes to the day-to-day program.

## 19.8.1 Interpolating a list in edition `0.1` (U2001)

:::mistake
Print the list as it is:

```diff include="steps/05-edition-0-1..mistakes/1:src/shelf.una" context="1" title="src/shelf.una"
--- a/src/shelf.una
+++ b/src/shelf.una
@@ -15 +15,2 @@
   @console.print("{lines.len} lines, {total(lines)} units")
+  @console.print("{lines}")
```

```text include="mistakes/1/expected/rendered.txt#L1"
[U2001] Error: interpolation converts `Int`, `Bool` and `Text` to text, and this value is `List[Line]`
```

*Why:* edition `0.1` interpolates only `Int`, `Bool` and `Text`. The message names both sides: what interpolation converts, and the type it was given, `List[Line]`.

*Fix:* interpolate the fields you want, or move the package to `0.2`, which interpolates any value that `==` compares, except a `Hashed`. See [U2001](https://una-lang.org/en/docs/errors/U2001/).
:::

## 19.8.2 Letting `una fix` rename a keyword (U0103)

:::mistake
Write the total with `let edit` and `for` in edition `0.1`:

```diff include="steps/05-edition-0-1..mistakes/2:src/shelf.una" context="1" title="src/shelf.una"
--- a/src/shelf.una
+++ b/src/shelf.una
@@ -8,3 +8,8 @@
 --- The units of every line, added up.
-total(lines: List[Line]) -> Int = lines.fold(initial: 0, step: fn(sum, line) -> sum + line.units)
+total(lines: List[Line]) -> Int
+=
+  let edit sum = 0
+  for line in lines
+    sum = sum + line.units
+  sum
 
```

```text include="mistakes/2/expected/rendered.txt"
[U0103] Error: `edit` is reserved for v0.2 (memory model)
    ╭─[ src/shelf.una:11:7 ]
    │
 11 │   let edit sum = 0
    │       ──┬─
    │         ╰─── `edit` is reserved for v0.2 (memory model)
    │
    │ Help: repair 1: rename it to `the_edit`; edit src/shelf.una:11:7..11:11 to "the_edit"
    │
    │ Note: run `una explain U0103` for an explanation
────╯
1 of 1 diagnostics have an edit that `una fix` applies (`una fix --dry-run` lists them)
```

The repair is meant for a program that uses `edit` as a name, and `una fix --dry-run .` lists it:

```text include="mistakes/2/expected/commands/fix.txt"
$ una fix --dry-run .
fixed src/shelf.una:11:7 U0103 rename it to `the_edit`
```

*Why:* in edition `0.1`, `edit` is a reserved word, not a keyword, so the checker reads it as a name that must change. The message says the rest: `reserved for v0.2 (memory model)` names the edition where `let edit` exists. Applied here, the rename gives `let the_edit sum = 0`, which does not parse.

*Fix:* change `edition` in `una.toml` to `"0.2"`. Do not apply the rename: offering it here is a known issue of una 0.4.0. See [U0103](https://una-lang.org/en/docs/errors/U0103/).
:::

## 19.8.3 Moving a package back (U0101, U7002)

:::mistake
Set the day-to-day program's edition to `0.2`:

```diff include="day-to-day..mistakes/3:una.toml" context="1" title="una.toml"
--- a/una.toml
+++ b/una.toml
@@ -3,3 +3,3 @@
 version = "0.1.0"
-edition = "0.3"
+edition = "0.2"
 
```

```text include="mistakes/3/expected/rendered.txt"
[U0101] Error: unexpected keyword `where`, expected `,` or `]`
    ╭─[ src/labels.una:41:38 ]
    │
 41 │   uses @printer: Printer[print_label where not dry_run]
    │                                      ──┬──
    │                                        ╰──── unexpected keyword `where`, expected `,` or `]`
    │
    │ Note: run `una explain U0101` for an explanation
────╯
[U0101] Error: unexpected text literal, expected `(` and the parameters
    ╭─[ src/labels.una:72:6 ]
    │
 72 │ test "a line that does not parse is left out"
    │      ┬
    │      ╰── unexpected text literal, expected `(` and the parameters
    │
    │ Note: run `una explain U0101` for an explanation
────╯
[U7002] Error: unknown table [contracts] in una.toml
    ╭─[ una.toml:10:2 ]
    │
 10 │ [contracts]
    │  ────┬────
    │      ╰────── unknown table [contracts] in una.toml
    │
    │ Note: run `una explain U7002` for an explanation
────╯
```

*Why:* the condition, the `test` declarations and `[contracts]` exist only in edition `0.3`. In `0.2`, the condition is a syntax error, so the message speaks of `where` as an unexpected keyword. `test` is a name in `0.2`, so `test "a line that does not parse is left out"` reads as the start of a function named `test`, and the text where its parameters should be is a syntax error too; the parser reports the first such line only. `[contracts]` is an unknown table of `una.toml`. Three diagnostics in two files point at one cause: the edition line.

*Fix:* keep the edition the package's constructs need. See [U0101](https://una-lang.org/en/docs/errors/U0101/) and [U7002](https://una-lang.org/en/docs/errors/U7002/).
:::

## 19.8.4 An operation outside its condition (U5001)

:::mistake
Remove the guard in `print_labels`:

```diff include="day-to-day..mistakes/4:src/labels.una" context="1" title="src/labels.una"
--- a/src/labels.una
+++ b/src/labels.una
@@ -45,4 +45,3 @@
     if line.units > 0
-      if not dry_run
-        @printer.print_label(line.sku, units: line.units)
+      @printer.print_label(line.sku, units: line.units)
       printed = printed + 1
```

```text include="mistakes/4/expected/rendered.txt#L1,L12-L18"
[U5001] Error: `@printer.print_label` may run where `not dry_run` is not proven
    │ Help 1: repair 1: guard the operation with `if not dry_run`
    │
    │ Help 2: repair 2: add `requires not dry_run` to the enclosing function; its callers then prove it
    │
    │ Note 1: obligation ob-e03b3850e838 (effect_condition) is refuted: not dry_run
    │
    │ Note 2: counterexample: dry_run = true, line = Line#0, line.sku = Text#0, line.units = 1, lines = List#0, lines.len = 1, printed = 0
```

*Why:* the header lets `print_label` run only where `not dry_run` holds, and the verifier found a run where it does not. The obligation's kind, `effect_condition`, says that it is a condition on an operation. The counterexample is `dry_run = true` with one line in stock, `line.units = 1`: the placeholders `Line#0`, `Text#0` and `List#0` are values the solver needed but whose details do not matter.

*Fix:* the first repair, `if not dry_run`. The second repair, `requires not dry_run`, would forbid every dry run. See [U5001](https://una-lang.org/en/docs/errors/U5001/).
:::

## 19.8.5 Dropping a locked condition (U3023)

:::mistake
Remove the condition from the header:

```diff include="day-to-day..mistakes/5:src/labels.una" context="1" title="src/labels.una"
--- a/src/labels.una
+++ b/src/labels.una
@@ -40,3 +40,3 @@
 pub print_labels(lines: List[Line], dry_run: Bool) -> Int
-  uses @printer: Printer[print_label where not dry_run]
+  uses @printer: Printer[print_label]
 =
```

```text include="mistakes/5/expected/rendered.txt#L1-L12,L16-L18"
[U3023] Error: the header of `print_labels` lets `@printer.print_label` run where `not dry_run` does not hold, which `una.toml` locks
    ╭─[ src/labels.una:41:26 ]
    │
 41 │   uses @printer: Printer[print_label]
    │                          ─────┬─────
    │                               ╰─────── the header of `print_labels` lets `@printer.print_label` run where `not dry_run` does not hold, which `una.toml` locks
    │
    ├─[ una.toml:11:26 ]
    │
 11 │ "labels.print_labels" = ["@printer: Printer[print_label where not dry_run]"]
    │                          ─────────────────────────┬────────────────────────
    │                                                   ╰────────────────────────── lock
    │ Note 1: obligation ob-35b380cf8520 (contract_lock) is refuted: not dry_run
    │
    │ Note 2: counterexample: dry_run = true
```

*Why:* the lock in `una.toml` says how much `print_labels` may ever do, and the header now grants more: printing in a dry run, as the counterexample `dry_run = true` shows. The diagnostic has two places in two files: the header, the primary place, and the lock in `una.toml`, marked `lock`. The obligation's kind is `contract_lock`.

*Fix:* restore the condition. To really change the rule, change the lock in `una.toml` too, where a reviewer sees it. See [U3023](https://una-lang.org/en/docs/errors/U3023/).
:::
