Diagnostic codes

generated from midad spec --json at build time; not edited by hand

100 codes. Every refusal midad makes carries one; the table below is the same table the binary reads, so midad explain CODE and this page cannot disagree.

Frontmatter and files 6

codeseveritymessage
E0001errornot an executable midad file: missing YAML frontmatter with a midad: version key
E0002errorfrontmatter is never closed with ---
E0003errorunsupported language version {} (this parser supports "0.1")
E0004errorinvalid module name {}
E0005errorinvalid frontmatter: {e}
E0006errorfrontmatter has both midad: and mdx: version keys

Syntax 27

codeseveritymessage
E0100error-
E0101error{open} is never closed
E0102errorblocks are nested too deeply
E0110errorinvalid command name {name}
E0111errora ``fn block holdsfunction name(param: type): return {` declarations
E0120errorexpected name: type = value;
E0121errorunknown type {t}
E0130errorparameter must look like name: type
E0140errorsignature must look like (number, float) -> float
E0141errorunknown native field; expected lib, symbol or sig
E0142errornative block needs both lib: and symbol:
E0150errorunknown ai:intent field; expected name, input, output, prompt or fallback
E0151errorai:intent needs name:, output: and prompt:
E0160errorinvalid variable name {name}
E0161error{kw} wants the {{ at the end of the line, with the body on the lines below
E0162error{kw} block is missing a closing }}
E0163errorunexpected text after }}: {rest}
E0164errorif let supports the Some(name), Ok(name) and Err(name) patterns
E0165errorexpected ; at the end of the statement
E0166errorfor needs an opening brace at the end of the line: for x in xs {
E0170errorunknown HTTP method {method}
E0171errorroute path must start with /, e.g. ```route:GET /items/:id
E0172errorinvalid route handler {h}
E0173errorroute {} {} names handler {} and also has statements
E0180errorinvalid type name {n}
E0181errorinvalid interface name {name}
E0182errora ``types block holdstype Name = ;andinterface Name {` declarations

Names, types and statements 33

codeseveritymessage
E0200error{name} is already defined
E0201errorstate {} is declared twice
E0202errorstate initializers must be constant literals
E0203error{name} is already declared in this scope
E0204errorroute {} {} is defined twice
E0210errorfunction {} returns {} but not every path returns a value
E0220errorentry point {e} is not defined by any fn block
E0221errorentry point {e} must take no parameters
E0222errorno entry point: set entry: in the frontmatter, define fn:main, a route, a command, or an exec block
E0230errortype mismatch: expected {}, found {}
E0231errorcannot bind a void value
E0232errorreturn needs a {} value
E0233errorthis block returns no value
E0234errorcannot assign to {name}: it is a const
E0235error{word} outside a loop
E0240errorassignment to undeclared variable {name}
E0241errorunknown variable {n}
E0242errorunknown function {name}
E0243errorif let {} needs {}, found {}
E0260error{name}(...) changes its first argument in place and answers nothing, so it has no value to use here
E0245error? needs an option or result value, found {}
E0246error? can only be used in a function that returns an option or result (this one returns {})
E0247errorthe par accumulator {acc} is {}; only a number can be summed across threads
E0248errorin a par body {acc} can only be updated as {acc} = {acc} + value
E0249errorreturn is not allowed inside a par body
E0250errora par body cannot contain another par
E0251errorhtml:{name} block is empty
E0252errorhtml:{name} is defined twice
E0253errorhtml:{name}: {m}
E0254errorno html:{t} block in this program
E0255errora before block runs before a route, and this program has no routes
E0256errorroute handler {} is not a function in this program
E0257errorroute handler {} must take one map and return a map

Permissions, imports and projects 22

codeseveritymessage
E0300error{name} is not permitted: missing {cap} permission (E0300 has one message per refusal: this one, a computed target that needs a grant, and eval_source without eval: true)
E0301errornative library {} requires the ffi permission
E0302errorai:intent {} requires ai: true in permissions
E0303errorroutes require the listen permission
E0304errorpersist: {p} needs both fs_read and fs_write permission for that path
E0305errorstatic: "{dir}" serves a directory, so it needs an fs_read grant that covers it
E0310errorimport cycle: {}
E0311error-
E0312errortwo imported files are both module {alias}
E0313errorimport {imp} must name a .md file
E0314error{} is imported but is not a midad program
E0315errorthis file is imported, so its exec block will not run
E0316errorthis file is imported, so its routes will not be served
E0317errorthis file is imported, so its commands will not exist
E0318error{alias} cannot be a module alias
E0319errorthis file is imported, so its before block will not run
E0341error{n} is a function, and a function name is not a value here
E0342error{n} has a fn parameter itself, so it cannot be passed as one
E0343errorfn is only a parameter type, not {what}
E0344error{} takes {} arguments, this passes {}
E0345error{n} is a fn parameter, so it cannot be assigned or reused as a variable name
E0346error{n} is both a variable here and the name of a function

Layout 3

codeseveritymessage
E0402error{} mounts a route but is not under routes/
E0403error{} is under routes/ but mounts no route and no route names one of its handlers
E0404errortwo files declare the module {}

Warnings 9

codeseveritymessage
W001warning{} has no midad.toml; using {} as the entry
W002warningimport {imp} reaches outside the project directory
W003warning{} has changed since it was vendored from {}: run midad vendor {} to refresh it, or delete {}/.vendor if you meant to fork it
W004warningmodule {} does not match the file name {stem}
W005warningfunction {shown} is not snake_case
W006warningstate {shown} is not snake_case
W007warningimported module {shown} is outside the conventional layout
W008warning/ now yields a float, so this is not integer division
W009warning{} takes a fn parameter and is never called, so its body is not checked
On this page