Wit

Error codes

Every stable diagnostic Wit can raise: 12 parser codes plus 14 runtime codes, and the one non-coded wit build message. Paste a code here to find its cause and fix.

Parser codes — 12

Raised during lex and parse, before any name is resolved. Source: packages/parser/src/errors.ts.

Parser codes
CodeCauseFix
E_UNCLOSED_NODEa block opener with no matching closeadd the close or use a self-closing form
E_UNCLOSED_COMMENTa block comment never terminatedclose the comment
E_UNCLOSED_DEFINITIONa def with no close or double-bangadd the close or the double-bang
E_UNCLOSED_PARENa parens call never closedadd the closing paren
E_MISMATCHED_CLOSEclose name differs from open namemake the close name match the open
E_MALFORMED_RECORDa bad record literaluse the hyphen delimiter in data-defs
E_UNCLOSED_COLLECTIONa collection never closedadd the closing bracket
E_UNCLOSED_SCRIPTa script with no percent-closeclose the script
E_UNCLOSED_RAW_NODEa raw node with no double-at closeadd the matching close
E_MIXED_PARAM_SOURCEopened one param form then added anotherthe form you open with is the form that closes
E_MALFORMED_FORM_FIELDa malformed form-fill field linefix the key colon value shape
E_UNTERMINATED_STRINGa quoted string not closedadd the closing quote

Runtime codes — 14

Raised during resolve and expand. Source: packages/runtime/src/errors.ts.

Runtime codes
CodeCauseFix
E_UNRESOLVED_REFERENCEa name binds to no definitiondefine it or fix the spelling
E_CIRCULAR_REFERENCEa reference or def cyclebreak the cycle
E_MISSING_REFERENCE_FILEa reference path does not existcorrect the path
E_MISSING_FIELDdotted access to an absent fieldcheck the field name — access is fuzzy
E_PARTIAL_SHAPE_MISMATCHan additive partial conflicts with the basematch the base shape
E_TYPE_MISMATCHa value-type mismatch in a comparison or usecompare like with like
E_DUPLICATE_DEFINITIONtwo non-additive defs share a namerename or make it additive
E_EXPANSION_DEPTH_LIMITexpansion recursion cap hitremove the runaway self-reference
E_NOT_ITERABLEeach over a non-collectioniterate a collection def
E_AMBIGUOUS_RECORD_KEYa fuzzy key match tiedisambiguate the key
E_SCRIPT_ERRORa script threwfix the script body
E_MISSING_RECORD_FIELDa record-arg omits a required capturesupply the missing field
E_EXTRA_RECORD_FIELDa record-arg supplies an unexpected fielddrop the extra field
E_LOAD_FAILEDload has no alias or exec is disabled or the program erroredconfigure the source and pass --allow-exec

Non-coded message

E_UNKNOWN_OUTPUT_FORMAT

— a wit build message (not a WitError) when the -o extension is unrecognised and no --format is given. Exit 1.

Verified repros

Each snippet below produced exactly the diagnostic shown.

@blockquote
hi
                 → E_UNCLOSED_NODE: unclosed @blockquote

@blockquote
hi
quote@           → E_MISMATCHED_CLOSE: expected blockquote@ but got quote@

@@pre
hi
                 → E_UNCLOSED_RAW_NODE: unclosed @@pre (expected pre@@)

<% a = 1         → E_UNCLOSED_SCRIPT: unclosed <% script block

@undefined       → E_UNRESOLVED_REFERENCE: Unresolved reference @undefined

#x: 1
#x: 2
@x               → E_DUPLICATE_DEFINITION: Duplicate definition #x

The greedy-bind trap (a pipes form before a later block use of the same node) surfaces as E_UNCLOSED_NODE — see gotchas.

See also

Syntax

· Gotchas · CLI · Config.