# Appendix B: Error codes

> Appendix B: the AL error codes the Alice compiler reports, what each means, how to fix it, and where the book explains it.

Canonical: https://alice-lang.org/documentation/learn/error-codes/

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

Every Alice compiler error has a code. The CLI prints it with the message, the location and a hint:

```text
error[AL0202]: data race: spawned task writes captured variable 'total'; send it
through a Channel or use an Actor
 --> main.al:2:20
  |
2 | Par.For(100) { |i| total += i }
  |                    ^^^^^
  = help: send the value through a Channel(T), use an Actor, or return it from 
the task
```

Messages and hints are available in English, Portuguese and Spanish: set `ALICE_LANG=pt` or pass `--lang es`.

## Language checks (AL01xx and AL02xx)

| Code   | Meaning                                                                        | Typical fix                                                    | Chapter                                                            |
| ------ | ------------------------------------------------------------------------------ | -------------------------------------------------------------- | ------------------------------------------------------------------ |
| AL0101 | parse error: a missing `end`, an unexpected token                              | close the block, fix the token                                 | [1.2](https://alice-lang.org/documentation/learn/first-program.md) |
| AL0102 | an `end` without a block                                                       | remove it or fix the nesting                                   |                                                                    |
| AL0103 | an unterminated string, character or interpolation                             | close it                                                       |                                                                    |
| AL0201 | a `case` misses enum variants                                                  | add the branches the message names                             | [7](https://alice-lang.org/documentation/learn/sum-types.md)       |
| AL0202 | a data race in concurrent code                                                 | `Atomic`, `Mutex(T)`, a channel, an actor, or return the value | [10](https://alice-lang.org/documentation/learn/safety.md)         |
| AL0203 | assignment to a `val`                                                          | use a plain variable                                           | [3](https://alice-lang.org/documentation/learn/common-concepts.md) |
| AL0204 | the type cannot be inferred from `nil`                                         | write `x : Type? = nil`                                        | [3](https://alice-lang.org/documentation/learn/common-concepts.md) |
| AL0205 | a type is required, as for a constant collection or a `getter` without a value | add `: Type`                                                   | [5](https://alice-lang.org/documentation/learn/strings.md)         |
| AL0206 | `yield` in a method without a block                                            | declare a block parameter                                      |                                                                    |
| AL0207 | an owned array escapes                                                         | keep it local, or drop `own`                                   | [9](https://alice-lang.org/documentation/learn/ownership.md)       |
| AL0208 | use after move                                                                 | reassign, or read through the new owner                        | [9](https://alice-lang.org/documentation/learn/ownership.md)       |
| AL0209 | `par for` iterations are not provably independent                              | remove the dependency, or use `for` or `prefix_sum`            | [11](https://alice-lang.org/documentation/learn/parallelism.md)    |
| AL0210 | a `pure def` or `rule` has an effect                                           | remove the effect, or drop `pure`                              | [10](https://alice-lang.org/documentation/learn/safety.md)         |
| AL0211 | `par a, b = ...` cannot fork                                                   | make both calls pure and independent                           | [11](https://alice-lang.org/documentation/learn/parallelism.md)    |
| AL0212 | a `safe def` reaches ambient authority                                         | pass in what it needs                                          | [10](https://alice-lang.org/documentation/learn/safety.md)         |
| AL0213 | a `borrow` parameter escapes                                                   | only read and lend it, or take it with `own`                   | [9](https://alice-lang.org/documentation/learn/ownership.md)       |
| AL0214 | a rule's domain has more than 2^32 cases                                       | narrow it, split it, or use `alice prove --smt`                | [13](https://alice-lang.org/documentation/learn/proofs.md)         |
| AL0215 | a native callback captures variables                                           | pass state through the C API's user data                       | [17](https://alice-lang.org/documentation/learn/native.md)         |
| AL0216 | a pointer operation outside `unsafe`                                           | wrap it in `unsafe ... end`                                    | [17](https://alice-lang.org/documentation/learn/native.md)         |
| AL0217 | one array passed as two parameters, one of them written                        | pass a copy                                                    | [9](https://alice-lang.org/documentation/learn/ownership.md)       |
| AL0218 | a `@[Stack]` value captured or stored on the heap                              | pass the fields it needs                                       | [9](https://alice-lang.org/documentation/learn/ownership.md)       |
| AL0219 | a value used after it was sent to another thread                               | send a copy                                                    | [10](https://alice-lang.org/documentation/learn/safety.md)         |
| AL0220 | strict mode: an expression has no static type                                  | annotate, call a typed method, or write `Any`                  | [10](https://alice-lang.org/documentation/learn/safety.md)         |
| AL0221 | a field that no `initialize` assigns                                           | assign it, give a default, or make it nilable                  | [6](https://alice-lang.org/documentation/learn/types.md)           |
| AL0230 | an actor message type is not sendable                                          | send immutable values: numbers, strings, records, tuples       | [15](https://alice-lang.org/documentation/learn/async.md)          |
| AL0231 | an actor captures mutable outside state                                        | build the state in `init`                                      | [15](https://alice-lang.org/documentation/learn/async.md)          |
| AL0001 | another compiler error                                                         | read the message                                               |                                                                    |

Codes from AL0222 to AL0229 are reserved for features designed for 1.0 ([Appendix E](https://alice-lang.org/documentation/learn/coming-in-1-0.md)) and are not reported yet.

## Type-checking errors (AL03xx)

Alice type-checks the generated code with the .NET compiler and reports its errors in Alice terms, with Alice type names:

| Code   | Meaning                                      | Example message                                             |
| ------ | -------------------------------------------- | ----------------------------------------------------------- |
| AL0301 | an operator is not defined for these types   | `'+' is not defined for Bool and Int32`                     |
| AL0302 | no such method                               | `undefined method 'open' for Box`                           |
| AL0303 | unknown name                                 | `undefined name 'totl'`                                     |
| AL0304 | type mismatch                                | `type mismatch: expected Int32, got String`                 |
| AL0305 | wrong argument type                          | `argument 1 of greet: expected String, got Int32`           |
| AL0306 | wrong number of arguments                    | `wrong number of arguments for f (given 2)`                 |
| AL0307 | unknown type                                 | `unknown type 'Foo' (missing require, using or a package?)` |
| AL0308 | not every path returns a value               |                                                             |
| AL0309 | a variable may be used before it is assigned |                                                             |
| AL0310 | a value may be `nil` here                    | `value may be nil here; check it ...`                       |
| AL0311 | ambiguous call                               |                                                             |
| AL0312 | generic type arguments cannot be inferred    | `cannot infer type arguments for 'f'`                       |
| AL0313 | a private member used from outside           | `'x' is private here`                                       |
| AL0314 | a read-only member assigned                  | `'x' is read-only`                                          |
| AL0315 | an instance member used without an instance  |                                                             |
| AL0300 | any other type-checking error                | the .NET message with Alice type names                      |

## Editor and command-line errors

`AL0401` is reported by the language server when an open `alice.toml` or `.alproj` does not parse. Command-line usage mistakes print `error:` with a `hint:` line and exit with status 2; internal failures exit with 70.

The [diagnostics reference](https://alice-lang.org/documentation/reference/diagnostics.md) has the full table with more examples.

## Continue reading

- Previous: [Appendix A: Keywords and operators](https://alice-lang.org/documentation/learn/keywords.md)
- Next: [Appendix C: Coming from Ruby, Crystal or C#](https://alice-lang.org/documentation/learn/from-ruby.md)
