# Diagnostic reference

> Interpret Alice compiler diagnostics and fix syntax, type, nil-safety, and race errors.

Canonical: https://alice-lang.org/documentation/reference/diagnostics/

[Documentation index](https://alice-lang.org/documentation/llms.txt) · [Complete book](https://alice-lang.org/llms-full.txt)

## Read a diagnostic

A compiler error identifies a code, a source location, and a message. The CLI adds a help hint where one is available.

```text
error[AL0202]: data race ...
  --> main.al:2:20
help: send the value through a Channel(T), use an Actor, or return it from the task
```

Start with the first meaningful error: later messages can be consequences of a missing token or unresolved type. .NET binding is mapped back to Alice file locations. Some underlying errors retain `CS` codes; common type errors use Alice's AL03xx codes and type names.

## Syntax and semantic checks

| Code   | Meaning                                                                                         | Fix                                                                                                                                                                                                |
| ------ | ----------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| AL0101 | Expected token, often a missing `end`                                                           | Check the block opener and close it.                                                                                                                                                               |
| AL0102 | Unexpected token, such as a stray `end`                                                         | Correct nesting or remove the extra token.                                                                                                                                                         |
| AL0103 | Unterminated string or literal                                                                  | Close the string, interpolation, character, or attribute.                                                                                                                                          |
| AL0201 | Non-exhaustive case                                                                             | Handle missing enum variants or add an intentional fallback.                                                                                                                                       |
| AL0202 | Possible data race                                                                              | Return a result, communicate by channel/actor, or use supported synchronization.                                                                                                                   |
| AL0203 | Reassigning an immutable binding                                                                | Keep `val` unchanged, or deliberately use a mutable local.                                                                                                                                         |
| AL0204 | Cannot infer a type from `nil`                                                                  | Write a nullable annotation such as `name : String? = nil`.                                                                                                                                        |
| AL0205 | Missing property/field type                                                                     | Add a type or initializer that determines it.                                                                                                                                                      |
| AL0206 | Yield has no usable block parameter                                                             | Declare a block signature or correct the supported yield form.                                                                                                                                     |
| AL0207 | An `own` array escapes (stored, captured, passed to code that keeps it)                         | Keep it local, lend it to a parameter that only reads and writes it, move it, or return it; or drop `own`. See [ownership](https://alice-lang.org/documentation/advanced/ownership.md).            |
| AL0208 | Use after move: a moved `own` local is read before it is reassigned                             | Reassign it with a fresh array first, or read through the local it moved to.                                                                                                                       |
| AL0209 | A `par for` loop is not provably independent                                                    | Write only the iteration's own cells, read shifted cells from another array, call pure code; or use a plain `for`. See [fork/join](https://alice-lang.org/documentation/concurrency/fork-join.md). |
| AL0210 | A `pure def` or `rule` is not pure                                                              | Remove the I/O or the write to outside state, or drop `pure`.                                                                                                                                      |
| AL0211 | `par a, b = ...` cannot fork                                                                    | Both values must be calls to pure methods, the second not reading the first result.                                                                                                                |
| AL0212 | A `safe def` reaches ambient authority                                                          | Pass the value in as an argument instead of reaching .NET statics, files, network or interop.                                                                                                      |
| AL0213 | A `borrow` parameter escapes                                                                    | Only index, size, iterate or lend it; take it with `own` if the method must keep it.                                                                                                               |
| AL0214 | rule domain larger than 2^32 cases                                                              | Narrow the ranges, or prove it for every input with `alice prove --smt`.                                                                                                                           |
| AL0216 | `Pointer(T)` used outside `unsafe`                                                              | Wrap the code in `unsafe ... end`, or write an `unsafe def`. Strings, arrays and numbers need no `unsafe`. See [calling C](https://alice-lang.org/documentation/advanced/ffi.md).                  |
| AL0217 | Conflicting borrow: one mutable value passed twice to a call that writes through one of them    | Pass a copy (`a.dup`) or a different value.                                                                                                                                                        |
| AL0218 | A `@[Stack]` value is captured by a block, stored in a heap type's field or put in a collection | Pass the fields it needs. A stack value lives only in its frame.                                                                                                                                   |
| AL0219 | A mutable value is used after it was sent through a `Channel` or `Actor`                        | Send `xs.dup`, or rebind the name before using it again.                                                                                                                                           |
| AL0230 | Actor message type is not sendable                                                              | Send numbers, `String`, enums, records/structs of sendable fields, tuples, immutable collections or actor handles.                                                                                 |
| AL0231 | Actor block captures a mutable local                                                            | Build the state in `init` (`Actor(S, T)`), send it as a message, or share it through `Mutex(T)`, `Atomic` or another actor.                                                                        |
| AL0215 | A callback passed to native code captures a variable                                            | Pass the state through the C function's user-data argument instead. See [calling C](https://alice-lang.org/documentation/advanced/ffi.md#callbacks).                                               |
| AL0001 | Other compiler error                                                                            | Read the specific message and source context.                                                                                                                                                      |

Do not fix AL0202 by hiding a shared write inside a helper. Fix the ownership or synchronization of the data. Read [race safety](https://alice-lang.org/documentation/concurrency/race-safety.md) for examples.

## Type checking

| Code   | Meaning                                 | Check                                                                                                  |
| ------ | --------------------------------------- | ------------------------------------------------------------------------------------------------------ |
| AL0301 | Operator unavailable for these operands | Operand types and conversions                                                                          |
| AL0302 | Undefined method/member                 | Spelling, receiver type, and package/namespace imports                                                 |
| AL0303 | Undefined name                          | Local declaration and scope                                                                            |
| AL0304 | Type mismatch                           | Expected type versus supplied value                                                                    |
| AL0305 | Wrong argument type                     | Parameter order and signature                                                                          |
| AL0306 | Wrong argument count                    | Required/default parameters and overload                                                               |
| AL0307 | Unknown type                            | `require`, `using`, restored references, and spelling                                                  |
| AL0308 | Missing result on a return path         | Every branch in a value-returning method                                                               |
| AL0309 | Read before definite assignment         | Branches/loops that may skip initialization                                                            |
| AL0310 | Possible nil                            | A checked branch or an intentionally justified `not_nil!`                                              |
| AL0311 | Ambiguous call                          | Overload and lambda types                                                                              |
| AL0312 | Cannot infer generic arguments          | Explicit argument types/constraints                                                                    |
| AL0313 | Inaccessible private member             | Public API boundary                                                                                    |
| AL0314 | Read-only member                        | Getter versus property and intended mutation                                                           |
| AL0315 | Instance required                       | Static versus instance call                                                                            |
| AL0300 | Other type-checking error               | Message with Alice type names                                                                          |
| AL0401 | LSP manifest error                      | `alice lsp`: an open `alice.toml` or `.alproj` does not parse (TOML or XML error at the reported line) |

## A small debugging workflow

1. Run `alice check` to isolate compilation from execution.
2. Check the first location and its expected type.
3. Confirm packages are restored and project references built.
4. Reduce the example if the message appears wrong.
5. Use `alice emit file.al` to inspect lowering when relevant.

An apparent missing method can come from a missing assembly reference rather than a parser problem. Use `alice install` and verify the manifest before rewriting valid source.

## CLI errors and languages

Usage errors print a hint and normally exit with 2; missing files and build/test failures normally exit with 1. Internal failures exit with 70. `--verbose` provides internal details when reporting a bug.

Set `--lang en`, `--lang pt`, or `--lang es`, or use `ALICE_LANG`. The default follows the OS UI culture. Include the exact command, Alice version, and minimal source when reporting a diagnostic issue.

## Continue reading

- Previous: [What changed in 0.13](https://alice-lang.org/documentation/reference/whats-new-0-13.md)
- Next: [Feature status and boundaries](https://alice-lang.org/documentation/reference/feature-status.md)
