Diagnostic catalogue

Every message Baa can produce, with a stable code. Codes never change meaning: if BAA102 means one thing today, it means the same thing in every future version. New diagnostics take new numbers.

Each entry has two wordings. The default is sheep-flavoured. The plain wording is used under --no-baa, BAA_NO_BAA=1 or when CI is set, and carries exactly the same information: the code, the severity and the source span are identical either way.

Placeholders like {0} are filled in with the specifics at the point of failure.

BAA0xx, Syntax#

The shape of the source is wrong. Reported before anything runs.

CodeSeverityDefault wordingPlain wording
BAA001errorThe sheep expected a closing {0} here.Expected a closing {0}.
BAA002errorThis character isn't part of the Baa alphabet: {0}Unexpected character: {0}
BAA003errorThis string wandered off without a closing quote.Unterminated string literal.
BAA004errorThis block comment never found its way back to the pen.Unterminated block comment.
BAA005errorThis number is a bit malformed: {0}Malformed number literal: {0}
BAA006errorThe flock expected {0} here, but found {1}.Expected {0}, found {1}.
BAA007errorThis escape sequence isn't one the sheep recognise: \{0}Unknown escape sequence: \{0}
BAA008errorYou can only put a name on the left of =. This isn't somewhere a value can graze.Invalid assignment target.
BAA009errorThis interpolation {{...}} is empty: there's nothing to print.Empty interpolation expression.
BAA010errorThis statement trails off before the sheep could finish reading it.Unexpected end of input.
BAA011errorThis is nested deeper than the flock can follow: more than {0} levels.Nesting depth exceeds the limit of {0}.
BAA012errorThis block string isn't laid out the way the sheep expect.Malformed block string literal.

BAA1xx, Names and scope#

Something is not declared, is declared twice, or cannot be assigned.

CodeSeverityDefault wordingPlain wording
BAA101error{0} has already been counted in this pasture.{0} is already declared in this scope.
BAA102error{0} is not part of the current flock.Undefined name {0}.
BAA103error{0} was shorn with const: its value can't grow back.Cannot assign to constant {0}.
BAA104errorreturn only makes sense inside a function. Out here it just echoes across the meadow.return outside of a function.
BAA105error{0} only makes sense inside a loop.{0} outside of a loop.
BAA106error{0} is used here before the flock has been introduced to it.{0} is used before it is declared.

BAA2xx, Calls#

A function was called with the wrong number of arguments, or declared badly.

CodeSeverityDefault wordingPlain wording
BAA201error{0} was called with too many sheep: it takes {1} but got {2}.{0} expects {1} argument(s) but received {2}.
BAA202error{0} was called with too few sheep: it takes {1} but got {2}.{0} expects {1} argument(s) but received {2}.
BAA203errorThis parameter name {0} is used twice in the same function.Duplicate parameter name {0}.
BAA204errorThis parameter list doesn't line up: {0}Invalid parameter list: {0}

BAA3xx, Runtime#

The program was valid but something went wrong while it ran.

CodeSeverityDefault wordingPlain wording
BAA301errorThe flock wandered somewhere unexpected: {0}Runtime error: {0}
BAA302errorYou can't {0} {1} and {2}. These sheep don't herd together.Unsupported operand types for {0}: {1} and {2}.
BAA303error{0} isn't something you can call. Only functions answer when called.{0} is not callable.
BAA304errorIndex {0} is outside the fence: this {1} has length {2}.Index {0} out of range for {1} of length {2}.
BAA305errorThere is no field called {1} on {0}.{1} is not a property of {0}.
BAA306errorDividing by zero. Even sheep know better than that.Division by zero.
BAA307errorThe flock has been counting too deep, the stack is full. (Is a function calling itself forever?)Maximum call depth exceeded.
BAA308errorUncaught: {0}Uncaught exception: {0}
BAA309errorYou can't herd {0}: only arrays, maps, strings and ranges can be looped over.Cannot iterate over {0}.
BAA310errorThis key isn't in the map: {0}Missing map key: {0}
BAA311error{0} expected {1} for argument {2}, but got {3}.{0}: argument {2} must be {1}, received {3}.
BAA312error{0} was asked to build {1} items. The pen only holds {2}.{0}: requested size {1} exceeds the limit of {2}.
BAA313errorThat gate is bolted: this run may not {0}.Capability denied: this run may not {0}.
BAA314error{0} cannot use that pattern: {1}.{0}: unsupported pattern: {1}.

BAA4xx, Modules and projects#

An import, a manifest or a file could not be resolved.

CodeSeverityDefault wordingPlain wording
BAA401errorNo module named {0} is grazing anywhere the shepherd can see.Module {0} could not be resolved.
BAA402errorThis flock has wandered in a circle: {0}Circular import detected: {0}
BAA403error{0} doesn't export anything called {1}.Module {0} has no export named {1}.
BAA404errorCouldn't read the file: {0}Could not read file: {0}
BAA405errorbaa.toml is not well formed: {0}Invalid manifest: {0}
BAA406errorbaa.lock no longer describes this flock: {0}Lockfile is out of date: {0}

BAA9xx, Lints#

Warnings from baa lint. These never make a program invalid.

CodeSeverityDefault wordingPlain wording
BAA901warning{0} is declared but never joins the flock.{0} is declared but never used.
BAA902warningThis code is past a return: no sheep will ever reach it.Unreachable code after return.
BAA903warning{0} is imported but never used.{0} is imported but never used.
BAA904warningThis condition is always {0}, so the branch never really decides anything.Condition is constantly {0}.
BAA905warninglet {0} is never reassigned: const {0} says what you mean.{0} is never reassigned; consider const.
BAA906warningThis empty block does nothing at all. Was something meant to graze here?Empty block.

Silencing a lint#

Lints (BAA9xx) can be turned off per rule:

bash
baa lint --disable BAA905 .

For the unused-name lints there is a lighter option: prefix the name with _. const _deliberately_unused = 1 is never reported.

Catching a runtime error#

BAA3xx errors are catchable. The value bound by catch is a map with code, message, file, line and column:

baa
try {
    baa flock[99]
} catch problem {
    baa "{problem.code} at line {problem.line}"
}