Error codesalpha
What moxzi's error and warning codes mean, and what to do about them.
moxzi uses moc's error codes, so a code means the same thing in both. For how to read an error, see Fixing build errors.
Common errors#
| Code | Meaning | What to do |
|---|---|---|
| M0096 | expression of type T cannot produce expected type U | the generic check-mode mismatch; read the note for the inferred type |
| M0057 | unbound variable | typo, missing import, or a name not in scope |
| M0026 | unbound variable in a path | the module qualifier does not resolve |
| M0029 | unbound type | the type name does not resolve |
| M0028 / M0030 | field / type field does not exist | Wrong qualifier, or wrong package version |
| M0020 | unresolved import | a missing mo: package or a wrong relative path |
| M0006 | import cycle | break the cycle; moxzi names the path |
| M0016 | cannot use x before y has been defined | reorder, or wrap in a function |
| M0055 | cannot infer type of forward variable | a binding without a type annotation reads a value declared later: annotate it (var v : Nat = seed(i)) or reorder |
| M0157 | block contains non-productive definition | a type defined only in terms of itself (type T = T), in any body — actor, object, module or block |
| M0001 | unexpected token | A syntax error. i<22 is one: < and > are comparisons only with spaces on both sides; otherwise they start type arguments. Write i < 22 |
| M0031 / M0032 | shared function has a non-shared parameter / return type | only shared types cross a message boundary |
| M0072 | field does not exist in {…} | the record literal is missing it |
| M0073 | expected mutable assignment target | declare the binding var |
| M0077 | a shared function is only allowed as a public field of an actor | move it into the actor |
| M0082 | expected iterable type | .vals() / .keys() |
| M0088 | expected async type | you're awaiting something that isn't a future |
| M0037 / M0038 | misplaced await/async; try enclosing in an async function/expression | |
| M0064 | misplaced ! | there is no enclosing do ? { } |
| M0097 | expected function type | you're calling something that isn't a function |
| M0102 / M0103 | cannot infer the type of a wildcard / variable | add an annotation |
| M0112–M0117 | pattern cannot consume the expected type | tuple, option, object, variant, operator and general forms |
| M0119 | show is not defined for this type | debug_show needs a showable type |
| M0124 / M0125 | public actor field has a non-shared function type / is not a manifest function | |
| M0141 | an actor or actor class must be the only non-imported declaration | move declarations into the actor body |
| M0175 | to_candid argument must have a shared type | |
| M0184 / M0261 | cannot infer the type of this or-/and-pattern | annotate it |
| M0189 / M0260 | different bindings in pattern alternatives / bound in both and-pattern legs | |
| M0225 | a mixin cannot be an entry point | include it in an actor |
| M0233 | cannot resolve implicit argument | pass it explicitly |
| M0238 | break/continue outside a loop |
Codes specific to moxzi, or worded differently#
| Code | Meaning | What to do |
|---|---|---|
| M0069 | An actor declared inside an expression or function | Move it to the top level. moxzi reports M0069 alone; moc also reports M0037 and M0038 |
M0057 for prim | prim is only available with MOC_UNLOCK_PRIM set | Use the Prim module through the standard library instead |
| M0096 with argument counts | A call passes N arguments but the function takes M, after implicit arguments | Check the call's arguments |
| M0250 | A stable variable has an initial value under --enhanced-migration | Remove it; the migration chain supplies the value |
| M0254 (warning) | A stable variable no migration in the chain produces | Add a migration, or build with --stable-baseline to make it an error |
| M0267 | A stable variable the chain can't produce from the deployed version. The message says which migration it was checked after | Add a migration that produces it, or fix the baseline |
| M0169, M0170, M0216 | An upgrade would drop a variable, change its type incompatibly, or lose data | See Migrations |
| M9000 | unimplemented: …, a construct moxzi doesn't support yet | Report it |
| M0000 | Several errors moc splits up: some parse errors (moc uses M0001), file and import failures, and internal errors | Read the message text; don't rely on the code alone |
Warnings#
Warnings are printed on successful builds. Control them with -A, -W and -E (see Building).
| Code | Meaning |
|---|---|
| M0089 | ignore on a value that's already () |
| M0145 | A pattern doesn't cover every value, so a switch or let can fail |
| M0146 | A pattern case is never matched |
| M0194 | Unused identifier |
| M0198 | Unused field in a pattern |
| M0254 | A stable variable no migration produces |
| M0265 | A mixin's capability doesn't match |
| M0266 | A floating-point literal has more digits than a Float can hold; the message says what it rounds to |
M0223, M0235, M0236 and M0237 are off by default, as in moc. moxzi doesn't report every warning moc does.
Runtime errors#
A trap or rejection at runtime uses the Internet Computer's message format:
| Message | When |
|---|---|
IC0503: Error from Canister ID: Canister called ic0.trap with message: '…'. | A Motoko trap, such as a failed assert or Runtime.trap |
IC0502: Error from Canister ID: Canister trapped: stack overflow. | The wasm stack overflowed |
self-calls nested more than 512 deep (a runaway async chain?) | A chain of self-calls went past 512 |
Canister exceeded the limit of 40000000000 instructions for single message execution | On the IC: a message ran too long. moxzid enforces --instruction-limit instead |
Reject codes follow the IC's numbering: 1 system fatal, 2 system transient, 3 destination invalid, 4 canister reject, 5 canister error, 6 unknown.