moxzi
Docs / Reference / Error codes

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#

CodeMeaningWhat to do
M0096expression of type T cannot produce expected type Uthe generic check-mode mismatch; read the note for the inferred type
M0057unbound variabletypo, missing import, or a name not in scope
M0026unbound variable in a paththe module qualifier does not resolve
M0029unbound typethe type name does not resolve
M0028 / M0030field / type field does not existWrong qualifier, or wrong package version
M0020unresolved importa missing mo: package or a wrong relative path
M0006import cyclebreak the cycle; moxzi names the path
M0016cannot use x before y has been definedreorder, or wrap in a function
M0055cannot infer type of forward variablea binding without a type annotation reads a value declared later: annotate it (var v : Nat = seed(i)) or reorder
M0157block contains non-productive definitiona type defined only in terms of itself (type T = T), in any body — actor, object, module or block
M0001unexpected tokenA syntax error. i<22 is one: < and > are comparisons only with spaces on both sides; otherwise they start type arguments. Write i < 22
M0031 / M0032shared function has a non-shared parameter / return typeonly shared types cross a message boundary
M0072field does not exist in {…}the record literal is missing it
M0073expected mutable assignment targetdeclare the binding var
M0077a shared function is only allowed as a public field of an actormove it into the actor
M0082expected iterable type.vals() / .keys()
M0088expected async typeyou're awaiting something that isn't a future
M0037 / M0038misplaced await/async; try enclosing in an async function/expression
M0064misplaced !there is no enclosing do ? { }
M0097expected function typeyou're calling something that isn't a function
M0102 / M0103cannot infer the type of a wildcard / variableadd an annotation
M0112–M0117pattern cannot consume the expected typetuple, option, object, variant, operator and general forms
M0119show is not defined for this typedebug_show needs a showable type
M0124 / M0125public actor field has a non-shared function type / is not a manifest function
M0141an actor or actor class must be the only non-imported declarationmove declarations into the actor body
M0175to_candid argument must have a shared type
M0184 / M0261cannot infer the type of this or-/and-patternannotate it
M0189 / M0260different bindings in pattern alternatives / bound in both and-pattern legs
M0225a mixin cannot be an entry pointinclude it in an actor
M0233cannot resolve implicit argumentpass it explicitly
M0238break/continue outside a loop

Codes specific to moxzi, or worded differently#

CodeMeaningWhat to do
M0069An actor declared inside an expression or functionMove it to the top level. moxzi reports M0069 alone; moc also reports M0037 and M0038
M0057 for primprim is only available with MOC_UNLOCK_PRIM setUse the Prim module through the standard library instead
M0096 with argument countsA call passes N arguments but the function takes M, after implicit argumentsCheck the call's arguments
M0250A stable variable has an initial value under --enhanced-migrationRemove it; the migration chain supplies the value
M0254 (warning)A stable variable no migration in the chain producesAdd a migration, or build with --stable-baseline to make it an error
M0267A stable variable the chain can't produce from the deployed version. The message says which migration it was checked afterAdd a migration that produces it, or fix the baseline
M0169, M0170, M0216An upgrade would drop a variable, change its type incompatibly, or lose dataSee Migrations
M9000unimplemented: …, a construct moxzi doesn't support yetReport it
M0000Several errors moc splits up: some parse errors (moc uses M0001), file and import failures, and internal errorsRead 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).

CodeMeaning
M0089ignore on a value that's already ()
M0145A pattern doesn't cover every value, so a switch or let can fail
M0146A pattern case is never matched
M0194Unused identifier
M0198Unused field in a pattern
M0254A stable variable no migration produces
M0265A mixin's capability doesn't match
M0266A 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:

MessageWhen
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 executionOn 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.

On this pageCommon errorsCodes specific to moxzi, or worded differentlyWarningsRuntime errors