Skip to content

Language

Diagnostic code registry

Every diagnostic has a stable code, a severity, a message, a primary source span (when one exists), and optionally: expected/actual types, related notes, a help line and a safe fix suggestion. The JSON form (t0 check --json) is the interface for tools and agents; message text is for people and may change without notice.

A suggestion is marked safe only if applying it cannot change financial meaning, remove a check, or add a capability or permission. Suggestions that add requires lines or grants are never generated.

A test (t0-diag, registry_matches_the_document) fails if a code in the code registry is missing here, or a code here is missing from the registry.

Syntax (E-SYN)#

code meaning
E-SYN-UNEXPECTED-CHAR a character that starts no token
E-SYN-UNTERMINATED-STRING a string literal without its closing quote
E-SYN-UNTERMINATED-COMMENT a block comment without */
E-SYN-BAD-ESCAPE an unknown escape in a string
E-SYN-BAD-NUMBER a malformed numeric or duration literal
E-SYN-NUMBER-RANGE an integer literal outside i64, or more than 18 decimal places
E-SYN-EXPECTED the parser expected one thing and found another
E-SYN-CHAINED-COMPARISON a < b < c
E-SYN-MISSING-LANG no lang header, or it is not the first header
E-SYN-UNSUPPORTED syntax reserved for a later version
E-SYN-TOO-DEEP constructs nested more than 128 levels deep (expressions, blocks, types, patterns, else if chains)

Versions (E-VER)#

code meaning
E-VER-SYNTAX a malformed version or range
E-VER-LANG the program's lang range excludes this compiler's language version
E-VER-HOST wrong host name, or the host API version is outside the program's range
E-VER-IR an artifact's IR version is not executable by this runtime
E-VER-FEATURE the program uses a construct from a newer language version than its lang range allows (write lang ">=0.2.0, <0.3.0";)

Names (E-RES)#

code meaning
E-RES-UNKNOWN-NAME no binding, item, module, contract or prelude name
E-RES-DUPLICATE two items, fields, variants or parameters with one name
E-RES-UNKNOWN-TYPE a type name that does not exist
E-RES-UNKNOWN-MODULE import of a module that does not exist
E-RES-UNKNOWN-FUNCTION a function the module does not have
E-RES-UNKNOWN-VARIANT an enum variant that does not exist
E-RES-UNKNOWN-METHOD a method the type does not have

Types (E-TYPE)#

code meaning
E-TYPE-MISMATCH expected one type, found another
E-TYPE-ARITY wrong number of arguments or type arguments
E-TYPE-CANNOT-INFER a type that context does not determine ([], None)
E-TYPE-MISSING-FIELD a struct literal without a field
E-TYPE-UNKNOWN-FIELD a field the type does not have
E-TYPE-IMMUTABLE assignment to an immutable binding
E-TYPE-NOT-A-PLACE assignment to something that is not a variable or field
E-TYPE-MISSING-RETURN a non-Unit function that can reach its end
E-TYPE-TRY ? where the function cannot propagate that error
E-TYPE-NONEXHAUSTIVE a match that misses a case
E-TYPE-PATTERN a pattern that does not fit the scrutinee
E-TYPE-OPERATOR an operator not defined for these (non-financial) types
E-TYPE-NOT-CALLABLE calling something that is not a function
E-TYPE-LOOP-CONTROL break/continue outside a loop
E-TYPE-MAIN main with parameters or an unsupported return type
E-TYPE-CONST a const initializer that is not constant
E-TYPE-HANDLE an attempt to construct or read inside a host handle
E-TYPE-RECURSIVE a struct or enum that contains itself directly

Financial and temporal (E-FIN, E-TIME)#

code meaning
E-FIN-DIMENSION an operation the dimension table does not define (Price + Quantity)
E-FIN-MIXED-NUMERIC mixing Int, Decimal, Float without an explicit conversion
E-FIN-CURRENCY-CODE an invalid currency code
E-FIN-CURRENCY-MISMATCH (runtime) combining or comparing two currencies
E-TIME-LITERAL a timestamp("…") literal that is not RFC 3339 UTC
E-TIME-PARSE (runtime) a timestamp string that is not RFC 3339 UTC

Strategies (E-STRAT)#

code meaning
E-STRAT-NOT-SIGNAL something that is not a signal used inside a strategy
E-STRAT-ARG-NOT-CONSTANT a signal operation's argument that is not a literal, parameter or enum value
E-STRAT-RULE-NOT-BOOL a rule condition that is not Signal<Bool>
E-STRAT-ACTION a rule whose right-hand side is not order(…)
E-STRAT-PARAM-TYPE a strategy parameter type that is not Int, Decimal, Quantity or Ratio
E-STRAT-OUTSIDE a signal operation used outside a strategy
W-STRAT-NO-RULES a strategy that can never act

Decorators (E-DECO)#

A decorator is @name(key: value, …) before a strategy parameter (language 0.2). Only @param exists; see script-kinds.

code meaning
E-DECO-PLACE a decorator anywhere but on a strategy parameter (on a function's, for instance)
E-DECO-UNKNOWN a decorator that is not @param, or a key @param does not have
E-DECO-VALUE a key given twice, a value of the wrong kind, min above max, a step that is not positive, a range outside what the parameter's type holds, or a switch on something that is not an Int or with a range or off of its own
E-DECO-REF above or below naming something that is not another decorated parameter of the same strategy, or a cycle of them

Capabilities (E-CAP)#

code meaning
E-CAP-NO-HOST requires without a host header
E-CAP-UNDECLARED an operation of a contract the program did not require
E-CAP-UNKNOWN a required contract the host does not expose
E-CAP-VERSION the host's contract version is outside the required range, or differs from the one the artifact was compiled against
E-CAP-UNKNOWN-OP an operation the contract does not have
E-CAP-DUPLICATE the same contract required twice
E-CAP-UNAVAILABLE (before or during a run) an exposed operation that is not available here now
W-CAP-UNUSED a required contract that nothing uses
W-DEPRECATED a deprecated operation; names the replacement

IR (E-IR)#

code meaning
E-IR-FORMAT not a T0 IR artifact, or malformed JSON
E-IR-HASH the body does not match its hash
E-IR-INDEX a type, function, local or const index out of range
E-IR-TYPE an expression whose declared type is not what its operation produces
E-IR-OPERATOR an operator applied to types the dimension table does not allow
E-IR-STRUCTURE loop control outside a loop, ? without a carrier, malformed match
E-IR-CAPABILITY a host call not covered by the artifact's requirements
E-IR-STRATEGY a malformed strategy graph

Permissions (E-PERM)#

code meaning
E-PERM-DENIED a needed permission the session has not granted

Runtime (E-RT, E-NUM)#

code meaning
E-RT-NO-ENTRY running a program with no main
E-RT-FUEL the step budget ran out
E-RT-DEPTH the call-depth limit was reached
E-RT-LIMIT-COLLECTION a list or string grew past its limit
E-RT-TIMEOUT the wall-time limit was reached
E-RT-CANCELLED the execution was cancelled
E-RT-INDEX a list index out of range
E-RT-EXPECT .expect(…) on None or Err
E-RT-HOST-CONTRACT the host returned a value that does not match its contract
E-RT-LIMIT-HOST-CALLS the execution made more host calls than its limit allows
E-RT-LIMIT-MEMORY the execution's strings, lists and records would hold more bytes than its memory budget (Limits::max_memory)
E-RT-INTERNAL an internal error (a bug), including a caught panic
E-NUM-OVERFLOW an arithmetic result out of range
E-NUM-DIV-ZERO division or remainder by zero
E-NUM-NONFINITE a Float result that is NaN or infinite
E-NUM-SCALE a decimal scale outside 0..=18
E-NUM-DOMAIN a function argument outside its domain (sqrt(-1))

Host (E-HOST)#

code meaning
E-HOST-STALE-HANDLE the object the handle referred to is gone, or the handle is from another process
E-HOST-UI-TIMEOUT the UI did not service a request in time
E-HOST-CANCELLED the host stopped the operation because the execution was cancelled
E-HOST-BAD-ARGUMENT an argument the host refuses (documented per operation)
E-HOST-FAILED the host failed internally; the message says how

Strict mode#

code meaning
E-STRAT-HANDLER a handler / state item of a strategy is malformed: not a call to a function of the program, the wrong number of arguments, a function that does not return a record with actions (and the next state), a bar length outside 1–1440
E-COMP-ROLE a component header names something that is not a role (strategy, risk, portfolio), or a risk or portfolio component declares a strategy
E-COMP-META a component's name is not lowercase letters, digits, - and _ (at most 64), or its version is not major.minor.patch
E-KIND-EXT the file is named for one kind (.tzr, .tzp, .tzi, .tzc, .tzs, .tzm) and declares another, or declares nothing of it; the help names the extension it belongs to
W-EXT a .tz file declares a component: it still works, and the help names the extension it would have as a kind of its own (.tzr, .tzp, .tzi, .tzs); an unsaved buffer is not told
E-COMP-ENTRY a component lacks its entry point (authorize for a risk policy, allocate for a portfolio controller), gives it another signature than the role fixes, or has a main; a strategy component declares no strategy
E-COMP-CAPABILITY a risk or portfolio component requires a contract other than its own (a policy reads what it is given and answers: no market, no files, no orders), or does not require its own
E-COMP-CONFIG a component's Config holds something other than plain values (numbers, Money, Quantity, Ratio, text, flags, lists and options of those), is declared and not taken as the first parameter of the entry point, or is taken and not declared
E-MOD-LOAD an imported module cannot be read: missing, outside the program's folder, not a .tz path, too big, too deep, too many, or the host lends no files
E-MOD-CYCLE modules import each other (the message shows the chain)
E-MOD-ITEM a module says host, requires or mode, or holds a strategy
E-MOD-ALIAS the alias of a module names two modules, or is a standard module or a contract
E-STRAT-WARM-UP warm_up N days; is declared twice, N is not a whole number of days from 1 to 3660 written in the strategy, or it names a parameter that is not an Int
E-STRAT-UNHANDLED-REJECTION under mode "strict";, a strategy sends orders and neither halts on the first refusal (halt_on_error;) nor reads refused(rule), rejected(rule) or last_error()
E-UNUSED-RESULT under mode "strict";, a Result or Option computed and dropped (a warning, W-UNUSED-RESULT, otherwise)

Warnings#

code meaning
W-UNUSED-RESULT a Result or Option computed and dropped

Contract-specific codes (E-WS-*, E-MKT-*, E-BT-*) are owned by the contracts that document them (../api/host-api.md), not by this registry.