---
title: "Diagnostics"
description: "Read real Atoll compiler output — the diagnostic families you hit first, the code that produces each one, and the fix."
---

> Documentation Index
> Fetch the complete documentation index at: https://docs.atoll.workreef.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Diagnostics

Every diagnostic on this page is real output, produced by running the compiler
on the source shown next to it. The shape is always the same:

```text
severity[CODE]: message at file:line:column
```

followed by a summary line — `N error(s) found` when the compilation failed, or
`OK (N diagnostics)` when only warnings and hints were emitted. Warnings and
hints never stop a build.

## Two commands, two gates

`atoll check` resolves names, types, effects, and errors. `atoll build` also
lowers the program to WebAssembly. **A program can pass `check` and fail
`build`**, so treat `check` as a fast inner loop and `build` as the real
acceptance test:

```atoll fail
import intrinsics

fn main() int {
    x := unsafe { intrinsics.memory_size() }
    return 1
}
```

```text
$ atoll check src/main.at
OK (0 diagnostics)

$ atoll build src/main.at
`main` (#6220) did not lower: [UnloweredIntrinsic("memory_size")]
1 error(s); build aborted
```

The refusal names the construct the backend could not turn into wasm. Only
*reachable* code is lowered, so an unused function containing such a call will
never report it.

[Feature Status](https://docs.atoll.workreef.dev/language/feature-status/) lists which stdlib methods are
currently in this state.

## Unresolved names — ATOLL1009

The resolver runs before typing, so a misspelled name is reported on its own
and nothing downstream of it is trustworthy.

```atoll refused=ATOLL1009
struct WorkItem {
    title string
    done  bool
}

fn open_titles(items []WorkItem) []string {
    mut out: []string = []
    for item in items {
        if !item.done {
            out.push(itm.title)
        }
    }
    return out
}
```

```text
$ atoll check src/main.at
error[ATOLL1009]: unresolved name `itm` at src/main.at:10:21
1 error(s) found
```

The range points at the *use*, not at a declaration, because the compiler has
no candidate to point to. The same code covers a name that exists but is not
in scope: a `private` declaration in another file, or a member missing from an
`import` list.

```atoll
struct WorkItem {
    title string
    done  bool
}

fn open_titles(items []WorkItem) []string {
    mut out: []string = []
    for item in items {
        if !item.done {
            out.push(item.title.clone())
        }
    }
    return out
}

fn main() void {
    mut items: []WorkItem = []
    items.push(WorkItem { title: "ship", done: false })
    items.push(WorkItem { title: "review", done: true })
    println("${open_titles(items).len()} open")
}
```

A near miss on a *method* is a different code, because the receiver's type is
already known:

```atoll refused=ATOLL2003
fn shout(word string) string {
    return word.uppercase()
}
```

```text
$ atoll check src/main.at
error[ATOLL2003]: no method `uppercase` on type `string` at src/main.at:2:12
1 error(s) found
```

## Type mismatches — ATOLL2002

A mismatch names both types and, where the checker recorded one, the boundary
that established the expectation.

```atoll refused=ATOLL2002
struct WorkItem {
    title  string
    weight string
}

fn total_weight(items []WorkItem) int {
    mut total: int = 0
    for item in items {
        total = item.weight
    }
    return total
}
```

```text
$ atoll check src/main.at
error[ATOLL2002]: expected `int`, found `string` at src/main.at:9:17
1 error(s) found
```

The parenthetical suffix is the blame: `(from a type annotation)`,
`(in argument position)`, `(operands of a binary operator)`. It tells you
*which* side is the expectation, which is usually what you actually want to
change.

The mismatch you will hit first is `Option`. Indexing and `get` return `T?`,
never `T`:

```atoll refused=ATOLL1021
fn first_plus_one(xs []int) int {
    return xs.get(0) + 1
}
```

```text
$ atoll check src/main.at
error[ATOLL1021]: cannot apply `+` to `int?` — it is defined for integer and
floating-point operands, and `int?` has no matching operator `impl` at
src/main.at:2:12
1 error(s) found
```

The code is `ATOLL1021`, not `ATOLL2002`: the operand is not the wrong type
for a known operator, there is no `+` on `int?` at all. Open the option first:

```atoll
fn first_plus_one(xs []int) int {
    return (xs.get(0) ?? 0) + 1
}

fn main() void {
    println("${first_plus_one([41])}")
}
```

Related codes on the same axis: `ATOLL3010` for an unknown field and
`ATOLL3012` for a call arity error.

```atoll refused=ATOLL3012
fn rescale(value int, factor int) int {
    return value * factor
}

fn main() void {
    println("${rescale(3)}")
}
```

```text
$ atoll check src/main.at
error[ATOLL3012]: function `rescale` takes 2 arguments, but 1 was supplied
at src/main.at:6:16
1 error(s) found
```

## Non-exhaustive match — ATOLL2010

The message names the type and lists the variants you left out.

```atoll refused=ATOLL2010
enum Priority {
    Low
    Normal
    Urgent
}

fn marker(p Priority) string {
    match p {
        Low => "."
        Normal => "-"
    }
}
```

```text
$ atoll check src/main.at
error[ATOLL2010]: non-exhaustive `match` on `Priority` — missing: Urgent
at src/main.at:8:5
1 error(s) found
```

This is the diagnostic that turns adding an enum variant into a checklist. Add
the arm rather than a `_`, unless treating the remainder uniformly is a real
decision:

```atoll
enum Priority {
    Low
    Normal
    Urgent
}

fn marker(p Priority) string {
    match p {
        Low => "."
        Normal => "-"
        Urgent => "!"
    }
}

fn main() void {
    println(marker(Priority.Urgent))
}
```

The same code and the same rule govern [`catch`](https://docs.atoll.workreef.dev/language/errors/catch/)
arms, which are match arms over the error channel.

## `?` outside a fallible function — ATOLL3051

`?` returns through an error channel. A function without one cannot host it.

```atoll refused=ATOLL3051
error WorkError { EmptyTitle }

fn normalize(title string) string ! WorkError {
    clean := title.trim()
    if clean.is_empty() { error EmptyTitle }
    return clean.clone()
}

fn main() void {
    println(normalize("  ship  ")?)
}
```

```text
$ atoll check src/main.at
error[ATOLL3051]: `main` uses `error` or `?`, and its result `void` declares no
error to leave with at src/main.at:9:4
  help: declare one: `fn main() void ! WorkError`
error[ATOLL2002]: `?` passes this error on, and `main` declares no error to pass
it to at src/main.at:10:13
  help: declare one — `fn main() void ! WorkError` — so a failure leaves `main`
  with it; or handle it here with `match`, or take a fallback with
  `.unwrap_or(…)`
2 error(s) found
```

Two lines, one cause: `ATOLL3051` at the *declaration* that lacks the error
channel, and `ATOLL2002` at the `?` itself. Read the declaration-level one
first.

`main` is usually the place where propagation should stop and a decision
should be made, so handle the `Result` instead of widening `main`:

```atoll
error WorkError { EmptyTitle }

fn normalize(title string) string ! WorkError {
    clean := title.trim()
    if clean.is_empty() { error EmptyTitle }
    return clean.clone()
}

fn main() void {
    match normalize("  ship  ") {
        Ok(clean) => println("accepted: ${clean}")
        Err(EmptyTitle) => println("rejected: empty title")
    }
}
```

That program checks clean. `main` inherits the `error` effect from
`normalize`, as every caller of a fallible function does, and since `main`
declares no effect row there is nothing to say about it — see below.

## A body that produces no result — ATOLL3052

A function whose declared result is not `void` has to produce one, on every
path. The check is about the *end* of the body: a tail expression of the wrong
type is a different diagnostic ([ATOLL2002](#type-mismatch--atoll2002)), and
this one fires when a path reaches the end with nothing to produce — no tail at
all, an `if` with no `else`, or a loop that can end.

```atoll refused=ATOLL3052
fn round_trip(text string) string {
    encoded := text.to_bytes()
}
```

```text
$ atoll check src/main.at
error[ATOLL3052]: `round_trip` declares `string` and its body reaches the end
without producing one — end the body with a value, or `return` one on every
path
at src/main.at:1:1
1 error(s) found
```

The commonest way to meet it is an `if` that returns, with no `else`. When the
condition is false, the body goes on past the `if` and there is nothing after
it:

```atoll refused=ATOLL3052
fn sign(n int) string {
    if n > 0 {
        return "positive"
    } else if n < 0 {
        return "negative"
    }
}
```

```text
$ atoll check src/main.at
error[ATOLL3052]: `sign` declares `string`, and this `if` has no `else`: when its
condition is false the body reaches its end without producing one — give it an
`else` that produces a `string`, or `return` one after it at src/main.at:4:12
1 error(s) found
```

The place is the `if` that falls through — here the `else if`, since its
condition can be false too. A `for` loop at the end is the same: it ends when
what it walks runs out, and the error says so at the loop.

A `return`, an `error`, a `break`, a `continue`, and a `for { }` with no break
all leave without reaching the end, so a body ending in any of them is fine.
For a fallible function it is the **success** type that is owed:
`fn f(): void ! E` owes nothing, `fn f(): string ! E` owes a `string`.

## Effect rows — ATOLL2032 and ATOLL2031

The compiler infers what each function's body needs — whether it may suspend,
fail, spawn — and you do not write it down. Neither diagnostic here fires on
code that does not write an effect row: this program checks clean, although
`describe` and `main` both inherit `Suspend` from `load_title`.

```atoll
import task

fn load_title(id int) string {
    task.yield_now()
    return "item ${id}"
}

fn describe(id int) string {
    return load_title(id)
}

fn main() void {
    println(describe(7))
}
```

```text
$ atoll check src/main.at
OK (0 diagnostics)
```

They are about a `using [...]` row somebody wrote — a contract on a function,
which ordinary code does not carry. Write `using []` on `describe`, promising it
stays effect-free, and the promise is held to:

```atoll
import task

fn load_title(id int) string {
    task.yield_now()
    return "item ${id}"
}

fn describe(id int) string using [] {
    return load_title(id)
}

fn main() void {
    println(describe(7))
}
```

```text
$ atoll check src/main.at
warning[ATOLL2032]: fn `describe` inherits effect `suspend` from a transitively-called callee but its declared `using [..]` row does not list `suspend` at src/main.at:7:12
  label: `load_title` calls `yield_now` here at src/main.at:2:5
  help: fn `describe` inherits `suspend` because it calls `load_title`
fn `load_title` inherits `suspend` because it calls `yield_now`
fn `yield_now` is where `suspend` is introduced
OK (1 diagnostics)
```

Read the two apart:

- **`ATOLL2032` (warning)** — a declared row is narrower than the effects the
  function inherits through its calls. The chain says which call brought the
  effect in and where. It is a warning, so `atoll lint` fails on it.
- **`ATOLL2031` (hint)** — a declared row lists an effect the function inherits,
  and this records *where* it entered. Informational; there is nothing to fix.

Widen the row when callers genuinely should permit the capability; move the
call out when they should not; or delete the clause if the contract was not
meant. The effects are `Suspend`, `Error`, `Alloc`, `Spawn`, and `Cancel` — see
[Effects](https://docs.atoll.workreef.dev/language/concurrency/effects/).

## Missing trait implementations — ATOLL3100

A bound a function declares is checked against the type an argument actually
has, and a type that does not satisfy it is named along with the function that
required it.

```atoll refused=ATOLL3100
struct Handler {
    name string
    run  fn(int) -> int
}

fn twice(n int) int => n * 2

fn main() void {
    handlers := [Handler { name: "a", run: twice }]
    best := handlers.max()
    println("${best.is_some()}")
}
```

```text
$ atoll check src/main.at
error[ATOLL3100]: type `Handler` does not implement trait `Comparable`
(required by `max`): field `run` of type `fn(int) -> int` is not Comparable
at src/main.at:10:13
1 error(s) found
```

`max` is declared `where T: Comparable`, and `Comparable` is derived
structurally from a type's members — `Handler` has a function-typed field, so
there is nothing to order `run` by and the derive declines. The same shape
reaches `Map` and `Set`, whose keys must be `Hashable`.

A bound nothing could meet is refused where the call is checked, so `atoll
check` reports it as a build does: a type with no `impl` of a trait no derive
answers (`fn yell[T: Shout]` handed a type with no `impl Shout`), and a derived
trait a function member blocks, as `run` blocks `Comparable` here. A bound a
derive may still meet is judged where the generic is instantiated, which only a
build reaches.

String interpolation is **not** an example of this. `${item}` derives `Display`
structurally too, so a struct whose every field is displayable interpolates with
no `impl` at all:

```atoll
struct WorkItem {
    title string
    done  bool
}

fn main() void {
    item := WorkItem { title: "ship", done: false }
    println("${item}")
}
```

The derive declines only when a member cannot carry it, and that refusal is
`ATOLL2003` naming the field — *"field `run` of type `fn(int) -> int` is not
Display"* — rather than `ATOLL3100`. Write the impl when the derived rendering
is not the one you want:

```atoll
struct WorkItem {
    title string
    done  bool
}

impl Display for WorkItem {
    fn write_to(&self, out &mut string) void {
        out.append(if self.done { "[x] " } else { "[ ] " })
        out.append(self.title)
    }
}

fn main() void {
    item := WorkItem { title: "ship", done: false }
    println("${item}")
}
```

## Syntax cascades — ATOLL1xxx

The parser inserts recovery nodes so one bad construct does not hide the rest
of the file. The cost is that a single mistake can produce a spray of
diagnostics, several of them nonsense.

```atoll refused=ATOLL1006
struct WorkItem {
    title string
    done  bool
}

fn main() void {
    item := WorkItem { title: "Publish guide" done: false }
    println(item.title)
}
```

```text
$ atoll check src/main.at
error[ATOLL1006]: Expected '}' at src/main.at:7:47
error[ATOLL1022]: Expected type expression at src/main.at:7:53
error[ATOLL1019]: Invalid statement at src/main.at:8:5
error[ATOLL1019]: missing field `done` in construction of `WorkItem`
at src/main.at:7:13
error[ATOLL2002]: type mismatch: expected `void`, got `bool` (in argument
position) at src/main.at:7:53
warning[ATOLL4101]: `item` owes a destructor and is never used
at src/main.at:7:5
warning[ATOLL4100]: local binding `done` is declared but never used
at src/main.at:7:47
5 error(s) found
```

Seven diagnostics from one missing comma after `"Publish guide"`. A literal's
fields are separated by a comma on one line and by the newline across lines,
so this one needs its comma and the same literal spread down a column would
not.

The rule for any noisy run: **fix the first syntax error in each file and
rerun before reading anything else.** Recovery is not acceptance — a
placeholder node never becomes a runtime value.

## Warnings and lints

Three warnings show up constantly and none fails a build.

`ATOLL4100` flags a binding you never read:

```atoll
fn main() void {
    scratch := "ship".len()
    println("done")
}
```

```text
$ atoll check src/main.at
warning[ATOLL4100]: local binding `scratch` is declared but never used
at src/main.at:2:5
OK (1 diagnostics)
```

### `ATOLL4101` — an unused binding that owes a destructor

The same shape with a different consequence, and it gets its own code
because the advice above is wrong for it.

Atoll drops **on the path, not at end of scope**: a value nothing later
names is released right after the line that defined it. For an `int`
that is invisible. For a value with a `Drop` body it is the difference
between a guarded region and an unguarded one.

```atoll unit
struct Cell { n int }

struct Guard {
    c ^Cell
}

impl Drop for Guard {
    fn drop(&mut self) () {
        self.c.^.n = 1
    }
}

fn main() void {
    c := ^Cell { n: 0 }
    g := Guard { c: c }
    println("this line runs AFTER the guard let go")
}
```

```text
$ atoll check src/main.at
warning[ATOLL4101]: `g` owes a destructor and is never used, so it is
released here rather than at the end of the block at src/main.at:12:5
OK (1 diagnostics)
```

**Renaming it `_g` does not fix this.** That silences the warning and
changes nothing else — which is right for an unused `int` and is the
whole reason this is not `ATOLL4100`.

The fix is to **name the guard once after the region it guards**. A
value something later mentions is held to the end of its block, so one
mention anywhere below the region covers the region:

```atoll unit
struct Cell { n int }

struct Guard {
    c ^Cell
}

impl Drop for Guard {
    fn drop(&mut self) () {
        self.c.^.n = 1
    }
}

fn keep(g &Guard) () { }

fn main() void {
    c := ^Cell { n: 0 }
    g := Guard { c: c }
    println("this line runs while the guard is still held")
    keep(&g)
}
```

[Destruction](https://docs.atoll.workreef.dev/language/memory/destruction/) has the whole placement rule with
the measurements behind it, including the one that catches people out next: a
bare `{ }` block is not a boundary, while an `if` arm and a loop body are.

`ATOLL7002` is the naming lint, and it is on by default:

```atoll
struct workItem {
    Title string
}

fn MakeItem(name string) workItem {
    return workItem { Title: name }
}

fn main() void {
    println(MakeItem("ship").Title)
}
```

```text
$ atoll check src/main.at
warning[ATOLL7002]: struct name `workItem` should be `WorkItem` (Atoll uses
PascalCase for structs) at src/main.at:1:8
warning[ATOLL7002]: function name `MakeItem` should be `make_item` (Atoll uses
snake_case for functions) at src/main.at:5:4
OK (2 diagnostics)
```

`@allow(naming)` on a declaration suppresses it for that declaration:

```atoll
@allow(naming)
struct workItem {
    Title string
}

fn main() void {
    println(workItem { Title: "ship" }.Title)
}
```

Suppression is per-declaration and only applies to compiler-recognized lints.
Generic decorator syntax does not invent new warning categories, and nothing
suppresses a type error, an effect error, or a lowering refusal.

## Renamed collection methods — ATOLL2114

The collections took Rust's names: a list appends with `push` (`Vec::push`) and
appends a whole list with `extend` (`Vec::extend`), and a set adds with `put`,
which answers whether the value was new (`HashSet::insert`). A call by the old
name says the new one:

```atoll refused=ATOLL2114
fn main() void {
    mut xs: []int = []
    xs.add(1)
}
```

```text
error[ATOLL2114]: `List.add` is now `List.push`
  help: `xs.push(x)` appends `x`, as Rust's `Vec::push` does
```

Indexing follows Rust as well: `xs[i]` answers the element and stops the
program out of range, `xs[a..b]` the window and stops it likewise, and
`xs.get(i)` and `xs.get(a..b)` answer the optional. A program written
when `xs[i]` answered the optional reads it that way somewhere — `xs[i] ?? 0`,
`match xs[i] { Some(x) => … }` — and each of those is refused where it reads
it (`??` needs an optional, a variant pattern needs one), with `get` named.

## A type parameter nothing fixes — ATOLL2115

A generic call is built for the types its parameters stand for. When neither
the arguments nor the place the result goes say what one is, there is no type
to build for, and the call is refused where it is written:

```atoll refused=ATOLL2115
fn leading[T](xs []T) T? {
    return xs.get(0)
}

fn main() int {
    found := leading([])
    return 0
}
```

```text
error[ATOLL2115]: cannot infer type parameter `T` of `leading`: nothing in this call fixes it
  help: name it at the call (`leading[int](…)`), or give the value a type where it is bound (`xs: []int = …`), so `T` has one
```

Either spelling gives `T` a type:

```text
leading[int]([])          // name the type argument at the call
typed: []int = []         // or give the value a type where it is bound
leading(typed)
```

## A negative literal index — ATOLL2116

A position below zero is before the first element, so an index written as a
negative literal can only stop the program. It is refused where it is written,
as Rust refuses it. There is no last-element shorthand; the last element is
`xs[xs.len() - 1]`.

```atoll refused=ATOLL2116
fn main() int {
    xs := [1, 2, 3]
    return xs[-1]
}
```

```text
error[ATOLL2116]: a negative index is before the first element, so it can only stop the program — the last element is `xs[xs.len() - 1]`
```

An index that is computed (`xs[n]`) is tested when the program runs, where a
negative one is out of range and stops it, and `xs.get(-1)` answers `None`.

## An associated constant two traits declare — ATOLL2117

A constant belongs to a trait, and a type may implement any number of them. When
two traits that one type implements declare a constant of the same name, reading
it through the type says nothing about which is meant, and is refused. Neither
constants nor methods have a `Trait.NAME` spelling; read the constant where only
one trait is in view, through a parameter bounded by that trait alone.

```atoll refused=ATOLL2117
trait Width {
    const N: int
}

trait Height {
    const N: int
}

struct Box {}

impl Width for Box {
    const N = 2
}

impl Height for Box {
    const N = 3
}

fn area() int {
    return Box.N
}
```

```text
error[ATOLL2117]: `Box.N` is ambiguous: `Height` and `Width` each declare a constant `N`
  help: a constant has no `Trait.NAME` spelling, as a method has none; read it where one trait is in view, as `fn read[T: Height]() => T.N`
```

## Code families

The leading digits narrow the stage, which narrows the fix:

| Range | Stage | Example |
| --- | --- | --- |
| `1xxx` | Lexing, parsing, resolution | `ATOLL1006` expected `}`, `ATOLL1009` unresolved name — or a name position that got something that cannot be one, such as [a reserved query word](https://docs.atoll.workreef.dev/language/fundamentals/source/#keywords) |
| `2xxx` | Typing, exhaustiveness, effects | `ATOLL2002` mismatch, `ATOLL2003` no such method, `ATOLL2010` non-exhaustive |
| `3xxx` | Members, calls, fallibility, trait obligations | `ATOLL3010` unknown field, `ATOLL3012` arity, `ATOLL3051` `?` in a non-fallible fn, `ATOLL3052` a body that produces no result, `ATOLL3100` missing impl |
| `4xxx` | Dead and unused code | `ATOLL4100` unused local, `ATOLL4101` unused guard |
| `5xxx`, `6xxx` | Backend and monomorphization | `ATOLL6002` structural type-arity mismatch |
| `7xxx` | Style and advisory lints | `ATOLL7002` naming |
| `8xxx` | Comptime code and derivation | `ATOLL8002` a decorator applied where it cannot be, `ATOLL8016` a derivation the program asks for cannot be made (said at the call, with the field it stops at), `ATOLL8017` an `impl` of a derivable trait in a package that declares neither it nor the type |

A `5xxx` or `6xxx` code means checked source hit a representation edge, and it
only ever comes from `atoll build`. The common one is `ATOLL6002`, which
usually means you passed a builtin a closure of the wrong arity — check the
signature in `stdlib/`. Anything else in that range is
worth reporting as a compiler bug.

## Triage order

1. Fix the first **syntax** error in each file. Rerun.
2. Fix **unresolved** names — everything after them is a guess.
3. Fix the first **type** error in each constraint chain, reading the blame
   suffix to decide which side is wrong.
4. Satisfy **trait and exhaustiveness** obligations.
5. Decide **error and effect** policy: who propagates, who handles, which rows
   widen.
6. Only then run `atoll build` and address any **lowering** failure.

Working the list out of order wastes time on diagnostics that will disappear
on their own.

## Reporting a compiler bug

Include:

- the smallest source that reproduces it, in current syntax;
- whether `check` or `build` failed, and the full diagnostic text with code
  and range;
- the `atoll.toml` fields that matter (module, dependencies, host access, SQL
  datasources) when the failure is project-scoped;
- compiler revision and target.

Preserve the *first* unexpected diagnostic and delete unrelated code around
it. An `ATOLL2003` on a stdlib method is already a complete report — the
method name is the bug.

Source: https://docs.atoll.workreef.dev/language/diagnostics/index.mdx
