Mo error catalog

Every diagnostic the Mo toolchain gives, one row per code. A diagnostic is a record with a stable code, a category, a location, what, why, and zero or more fixes, each with a confidence; there are no warnings (design-v0/05, “Diagnostics teach”). mo check --json prints each record as one line of JSON.

  • what is the sentence printed at the finding. The row gives its template: each <placeholder> is filled in from the code at hand. A code whose findings take more than one shape shows the most common.
  • why is written once per code, here. It is where Mo’s philosophy is taught to a model that has never seen it.
  • mo fix says what mo fix does for the code: it applies every fix of confidence 100 and rewrites the file. no means the finding is fixed by hand.

Generated by zig build errors from the diagnostic tables in toolchain/src/ (lexer.zig, parser.zig, check.zig, caps.zig, loops.zig, fmt.zig). Do not edit this page: the corpus test fails when it differs from the tables.

codecategorywhatwhymo fix
MO0001syntaxunexpected characterMo source outside strings and comments is names, numbers, and the operators of grammar §1; this character is none of those.no
MO0002syntaxthis string does not close on the line it opens on; close it before the line ends, since mo fmt leaves a long line long, or write text that spans lines in a """ blockA string opened with ” closes on the same line; text that spans lines goes in a """ block.no
MO0101syntaxexpected <token>spec/grammar.md allows only this at this point in the production. The one-line if is a value only, if cond: a else: b, with both branches, each one expression, and a statement takes the block form; a variant’s fields are matched by name, as Short(by: n); is binds loosely inside a comparison, so (x is Ok(_)) == y takes its parentheses; and state, old, and result are keywords where the grammar reserves them, state inside a process and old and result inside the contracts that read them, so a binding there takes another name; and a string’s escapes are \n, \t, \r, \, ”, #, and \u{XXXX}, any other backslash refused.no
MO0102syntaxexpected an expressionAn expression starts with a literal, a name, a type name, (, [, !, -, try, if, case, fn, old, result, or any.no
MO0103syntaxexpected a typeA type is a type name such as UInt32 or List(T), or a tuple of two or more types such as (UInt32, String).no
MO0104syntaxexpected a patternA pattern is _, a name, a literal, a variant such as Some(x) or Short(by: n), or a tuple of patterns.no
MO0105syntaxexpected a declaration, a test, or the end of the fileA module is its header (module, expose, use, intent, never), then declarations, then tests, then the verified: line.no
MO0106syntaxthis cannot be assignedOnly a name or a field path such as copy.name can be assigned.no
MO0201typesthere is no <name> in scopeA name is a binding in scope, a parameter, or a function or variant declared in this module, named on one of its use lines, or in the prelude (toolchain/PRELUDE.md). Nothing else exists. reply_by is the asker’s deadline and reply_to is the asker itself, both bound only in an update arm for a message that carries a reply; elsewhere a call takes a Duration, and there is no asker to keep.no
MO0202typesthere is no type named <Type>A type is a prelude type, a type declared in this module, a name brought in by use, or a one-letter type parameter in a function signature.no
MO0203types<name> is exposed but not declared in this moduleThe expose line is the module’s table of contents; every name on it must be declared in the module (grammar, semantic rules).no
MO0204types<name> is on the expose line twiceThe expose line names each public declaration exactly once.no
MO0205types<name> is declared twice in this moduleOne name means one declaration in a module, so a reader never has to ask which one a call reaches.no
MO0206typesexpected <Type>, found <Type>Mo has no implicit conversion: a value is used only where its type is expected. Named conversions cross types.no
MO0207types<function> takes <n> arguments, found <m>Every parameter is passed at every call, and nothing else is: there are no defaults and no optional arguments.no
MO0208types<Type> has no field or function named <name>x.name reads a field of x’s struct, or calls name with x as its first argument; one of the two must exist.no
MO0209types<function> takes its arguments by position; <label>: is not one of themConstruction names every field exactly once; ordinary functions take arguments by position, while prelude rows declare their permitted labels explicitly.no
MO0210typestry applies to a Result or an Option; this is <Type>try passes an Error or a None up to the caller, so it applies to a Result or an Option inside a function that returns the same kind.no
MO0211typestry passes up <Enum>.<Variant>, but <Enum> has no variant <Variant>try re-tags an error, it never converts one: every variant of the error it passes up must exist in the function’s error type with the same name and fields.no
MO0212types<pattern> cannot match <Type>A pattern matches the shape of its subject’s type: a one-field variant positionally, a variant with more fields by name, a tuple by position.no
MO0213types<Type> has no impl <Trait>, which this call needswhere T: Trait promises the body that T has the trait’s functions, so every type passed as T needs an impl of that trait.no
MO0214types<form> <does what>, so it appears only in <place>Some forms belong to one place: result and old to contracts, assert to tests, any to properties, T.all and flows to never, break to a for, return to a function body.no
MO0215types<name> is not a var, so it cannot be assigned; bind a new name or make it var <name>Only var, inout, and state places change; a name bound with = is bound once, and an inout argument must be a var the caller holds.no
MO0216typesimpl <Trait> for <Type> is missing <function>An impl keeps the trait’s promise exactly: every function the trait lists, with Self replaced by the implementing type, and nothing else.no
MO0217types<literal> does not fit in <Type>Integers are sized; a literal must fit the type it is given, and overflow is never implicit.no
MO0222types<Type> is built by naming its fields: <Type>(<field>: ...)Construction is always by named fields (grammar §6), so a reordered struct never silently swaps two values.no
MO0223types<Process> is sent the messages of <row> but declares no <Message>; add message <Message> to it, with no reply.Listener.serve, Conn.lines, Conn.chunks, and HttpListener.serve make the runtime accept or read from that call on and send each result to the process into: names (design-v0/09, Net and Http; steps 20 and 44). A process’s message lines are its whole protocol, so the runtime sends only what the process declares it takes: every message the row sends, each with the one field type the row gives it, and no reply, since nobody waits for one.no
MO0301laws<function> has a body of <n> lines and the limit is 70; split it into named functions.A function body is at most 70 lines (chapter 2, shape laws), so a whole function is read at once. The fix is named helper functions.no
MO0303laws<function> takes <n> parameters and the limit is 6; group them in a struct.A function takes at most 6 parameters (chapter 2, shape laws); past that, the values belong together in a struct.no
MO0304lawsthis <if, case, for, or fn> is nested <n> deep in <function>; the limit is 3, so move the inner block into its own function.Nesting is at most 3 deep (chapter 2, shape laws): each if, case, for, and block anonymous function is a level. The inner block becomes its own function.no
MO0305laws<Process> keeps <n> state fields and the limit is 12; move related fields into a struct or a second process.A process state has at most 12 fields (chapter 2, shape laws); a bigger box is a struct field or a second process.no
MO0306laws<name> is bound twice in one scope; make it var <name>, or pick a new name.A name bound with = is bound once (chapter 2, honesty laws), so a reader never has to ask which value it holds. A value that changes is a var.no
MO0307laws<name> is bound but never used.Every binding is read (chapter 2, honesty laws): an unused one is dead code, or a bug where another name was used instead.yes: delete the line that binds the name, when its value holds no capability call, try, or process start, and no comment sits on the line
MO0308lawsthis case does not cover <pattern>; add an arm for it.Every case is exhaustive (chapter 2, honesty laws), so a value nobody handles is a compile error, not a crash.no
MO0309lawsthe <arm> arm hides <patterns> of <Type>; write an arm for each of them in its place.No catch-all arm on a closed enum (chapter 2, honesty laws): a _ arm would silently take every variant added later.no
MO0310lawsthe <Result or Option, or a pure value> from <call or one-line if> is dropped; <match it with case or pass it up with try>Every Result and Option is consumed (chapter 2, honesty laws): a dropped error is an error nobody handles. So is the value of a pure call, one that takes no capability or handle: its value is all it does, so dropping it is a mistake. So is a one-line if’s: the form is a value, never a statement, and only the last line of a body that gives a value may be one.no
MO0311laws<function> has requires <condition>, but no test rejects trips it.Every requires has a test rejects that trips it (chapter 2, contract laws). Tier 1 checks that a test rejects calls the function; tier 2 checks that the call trips.no
MO0312laws<name> has a default value; parameters have no defaults, so pass <value> at the call.No default parameters (chapter 2, honesty laws): every call shows every value the function receives.yes: drop the default, and pass it at every call in the file that leaves the parameter out
MO0313lawsan anonymous function is bound to <name>; pass it straight into <call> instead.An anonymous function is a call argument only, never stored or returned (chapter 2), so effects never hide in a value.no
MO0314laws<name> is a var and cannot be captured by the anonymous function; bind a plain name first.A var is never aliased (chapter 3, values): an anonymous function captures read-only, so it cannot hold a var.no
MO0315laws<name> is a var and cannot be sent to a process; bind a plain name first.A var is never aliased (chapter 3, values): a process that received one would see a value its owner still changes.no
MO0316laws<Process> is not a child of any supervisor; add a supervisor with child <Process>.A process not under a supervisor does not compile (chapter 3, processes): every crash has someone to restart it.no
MO0317lawsno mo test --write recorded this verified: line; delete it and run mo test --write on this file, which writes the line.The verified: line belongs to the toolchain (chapter 5): mo test —write computes it, writes it at the bottom of the file, and records it in .mo.ids against the file’s declarations. A line with no record, a different line, or declarations changed since was not computed for this code.no
MO0318laws<Module> uses <Module> uses <Module>; modules have no import cycles.Modules have no import cycles (chapter 2, shape laws), so each module is understood, checked, and cached after the ones it uses.no
MO0319lawsthe state field <name> is a <Type>, which has no zero value; give it = expr.A state field starts at its type’s zero value (0, "", [], None, false, and tuples and structs of those) unless it writes = expr (grammar, Session 5). An enum, a Time, a capability, a handle, or a refinement that refuses zero has none, so the process could not start.no
MO0320laws<Module> declares fn main, and so does <Module>; a program starts in one place.A program has one root, fn main(platform: Platform), in one of its modules (chapter 3, effects; Q18): its capabilities come from one place, and it starts in one place.no
MO0321lawsuse <Module> brings nothing into scope; name what you use, as in use <Module>{Type, function}.A use line names what it brings in, types and functions from the module’s expose line (grammar, Session 5), so every bare name in a file is found on its own use lines. There are no wildcards and no aliases.no
MO0322laws<Module> does not expose <name>; a use names only what is on a module's expose line.A module’s expose line is its whole public surface (grammar §2); everything else is private, so a use names only what the module exposes.no
MO0323laws<Module> is not a module of this program: there is no <path> under the program root.A program is a tree of files: A.B is a/b.mo under the program root, the nearest directory holding a mo.root file, else the main file’s own directory (grammar, Session 5). A use names a module of the program.no
MO0324lawsthis never cannot be checked: a run records no <Type> values, only structs, enums, and primitive values.A never is checked at the end of every test, test rejects, and property run, over the values of each type it reads with T.all that the run held (chapter 2, contract laws). A run records structs, enums, aliases, and primitive values; a capability, a trait, or an opaque type is not recorded, so a never over one would pass without checking anything, and a never that cannot be checked does not compile.no
MO0325teststhe refinement of <Type> admits none of the 200 values any(<Type>) generated; write its where as a range, such as value >= 1 and value <= 9, or generate the base type and build the value in the property.A property checks its claim over the values a type admits (chapter 4). any(T) of a refined type generates the base type and keeps what the where admits; when none of the first 100 candidates passes and the where compares value with integer literals, it generates between those bounds. When none of 200 passes, the property would check nothing, so it fails instead.no
MO0326tests<function> takes (<parameters>) here and (<parameters>) in recipe <Recipe>; take what the recipe takes.A recipe is the spec altitude of a module (chapter 6), and mo check —recipe holds an implementation to it: each of the recipe’s signatures is a function the implementation exposes with the same parameters, result, and requires, and at least the same ensures, and the recipe’s tests and nevers run against the implementation. A test or never the implementation keeps under a recipe’s name is the recipe’s, line for line. So a recipe and its implementations cannot drift apart.no
MO0327laws<Process> has invariant <sentence>, which reads old(state), but no test rejects starts or messages it.An invariant that reads old(state) is a claim about how an update may move the state, and like a requires it needs a test rejects (chapter 2, contract laws; step 20). Tier 1 checks, as it does for a requires, that a test rejects in the process’s module starts the process or sends it a message; the run checks that the test trips. Step 19’s mutation tests showed that a contract no test drives can be inverted and nothing notices.no
MO0401capabilities<call> has no within: deadline; add one, such as within: 100.ms.Every call that can wait carries a deadline (chapter 2, bounding laws), so nothing blocks forever; a timeout comes back as an ordinary error the caller handles.no
MO0402capabilities<call> cannot wait, so it takes no within:; remove the deadline.Only a call that can wait takes within: (the platform marks which ones, toolchain/PRELUDE.md); a deadline on a call that cannot wait says something false.no
MO0403capabilities<function> has no capability parameter, so it is pure and cannot use a <Capability>; take a <Capability> parameter.A capability is held only as a parameter and narrowed on the way down (chapter 3, effects), so a function’s signature is the complete list of what it can touch.no
MO0404capabilities<owner> writes through <its parameter, or a message's field>, and <value> was narrowed to read_only and only reads; hand it the Fs <value> was narrowed from.An Fs narrowed to read_only promises that nothing is written through it, so tier 1 follows it wherever this unit hands it on: into a function’s parameter, a process’s start argument, a supervisor’s child line, or a message’s field, through a name bound to it and through each branch of an if or a case, and refuses it where the call on the other side writes through what it is given; a write through it in the same unit is refused too (fs.write writes through logs, which was narrowed to read_only). The same code stands for a never with flows(T, into: Cap), which promises that no value of type T reaches a call on Cap: a reaches through ; the never forbids it.no
MO0405capabilitiesflows names a declared or prelude type first, such as flows(CardNumber, into: Events).flows(T, into: Cap) names a type first and a capability after into:, so the rule can be checked; a never that cannot be checked does not compile.no
MO0406capabilities<function> takes a <Capability>, but recipe <Recipe> needs <capabilities>; add <Capability> to its needs line.A recipe’s needs line is the list of capabilities its implementation may take (chapter 6), so every capability in its signatures is named there, and only capabilities are.no
MO0407capabilities<function> takes a Platform, which only main holds; take the parts it uses instead, such as an Fs or an Out.A Platform exists only as fn main’s parameter (Q18): main reads its parts and passes each one down, narrowed, so no other function can reach everything the program holds.no
MO0408capabilitiesthis module has no fn main(platform: Platform), so mo run has nothing to run; mo test runs its testsmo run starts a program at fn main(platform: Platform), the one place it receives its capabilities (Q18). A module without main has nothing to run; mo test runs its tests.no
MO0409capabilitiesthe anonymous function captures <name>, a <Capability or Handle>; pass <name> as a parameter to a named function instead.An anonymous function captures read-only, but a capability or a handle is authority: captured, it lets a call that takes only data, such as map, perform an effect no signature shows (chapter 3, effects). Authority travels only as a parameter, so a named function that takes it says what it touches.no
MO0410capabilities<name> went to another process in <Message>, so it is no longer this function's; use it before the send, or not at all.A message may carry a capability its message line declares (chapter 3, processes; step 20), and a capability in a message moves rather than being copied: once sent it is the receiving process’s, so two processes never act through one connection at once. The checker refuses every use of the name after the send in the function that sent it, and on the next pass of a for; a copy it cannot see, such as a start argument sent in one update and used in the next, still reaches the same connection.no
MO0411capabilities<Message>'s arm mentions reply_to but does not hand it to a state field; write state.<field> = ... reply_to ... once, and answer it later with reply.answer(value).An arm for a message that carries a reply answers the ask in one of two ways, never both and never neither (chapter 3, processes; step 31): its value is the reply, as it has always been, or it keeps the asker by moving reply_to into a state field and answers it from a later arm with reply.answer(value). reply_to moves as a capability in a message moves (MO0410): the arm names it exactly once, inside an assignment to a place under state, and every later read of it is refused, since the asker is the state’s now. A Reply the state drops without answering is no error: the asker times out at its own deadline, as it would if the process never answered.no
MO0501formatthis for has a pure body; write it as map, filter, or reduceA pure loop body is written with map, filter, or reduce, so a for always says an effect, a try, a break, or a return is inside (chapter 4, loops). mo fix rewrites the three accumulator loops (push into a list, push when a condition holds, fold into a var); any other pure body is rewritten by hand.yes: acc = acc.push(e) in a for over xs becomes acc = acc.concat(xs.map(fn(x) e end)); if c around acc = acc.push(x) becomes acc = acc.concat(xs.filter(fn(x) c end)); acc = e reading acc, acc += e, or acc -= e becomes acc = xs.reduce(acc, fn(so_far, x) … end)
MO0502formatthis comment sits inside a line the formatter joins; move it above the lineThe formatter never moves or drops a comment (toolchain/FORMAT.md, K5), and this one sits inside a line the formatter joins, such as parentheses that span lines. Put it on its own line above the statement.no