Repository navigation
Diagnostics
As of v1.0.0
The reader reports every problem it finds as a diagnostic. A diagnostic is one native JSON document: it follows SARIF's structure, and its fields have plain names. The text a terminal shows, SARIF and GitHub annotations are projections of that document, and its conversion to the Language Server Protocol (LSP) is given below, under Conversion to LSP.
The reader reports these problems, among others:
- a line that is none of the three shapes, or a colon line with an empty verb, a bang line with an empty verb, or an arrow line with an empty side, named by file and line,
E_LINE_SHAPE(see Language); - any other line that no form matches, such as
item : book Algebra,E_FORM_NONE; - a capture that fails its class, as in the example below,
E_CLASS, and a token longer than thelengthcap,E_CAPwithcaplength, neverE_CLASS(see Classes); - a bare name in an
isline that names no class,E_CLASS_UNDECLARED, and a placeholder whose class is undeclared,E_DECLARATIONof kindcapture(see Classes); - a class whose language is empty once intersected with the allowed code points: a class is legal whatever code points it names, so this is the note
N_CLASS_EMPTY, not an error (see Classes); - a placeholder name repeated within one form or within one
filetemplate, a secondfileline in one body, a form placeholder or a rule variable named like a placeholder of its language'sfiletemplate, or a class, term, primitive or cell declared under the name of a library function, a built-in class or a meta class,E_DECLARATIONof kindduplicate; - an
exampleline that does not fit its form,E_EXAMPLE, and an example whose library call fails, the library's own code,E_LIBRARY_DOMAINorE_LIBRARY_PARENT, covering the library call in the form'sdoesline; - a program that does not meet a
count, an unkeyed one or a keyed one in one group of its terms,E_PROGRAM_COUNT, or whose lines breakorder : strict,E_ORDER(see Terms and counts); - a declaration rejected when it is read: forms that shadow each other,
E_FORM_SHADOW; a class that can hold the literal that follows its placeholder,E_CLASS_OVERLAP; a form markedrestricts!whose constructor has neither an unkeyed count of1or1..*nor adefaultline,E_RESTRICTS, a keyed count never satisfying it on its own;defaultlines for one constructor that would by themselves exceed its multiplicity, or a group's multiplicity under a keyed count,E_DECLARATIONof kindconflict, so that no program ever reports a count failure produced by defaults alone; a rule cycle,E_RULE_CYCLE, or a class cycle,E_DECLARATIONof kindclass-cycle, each reported once, at its earliest declaring line; a duplicate rule,E_RULE_DUPLICATE(see Rules and plans); - in a body that declares a primitive, a constructor that is not a primitive, is not rewritten by a rule and is not declared
fact,E_CONSTRUCTOR_UNBOUND; a primitive that has nowritesline and is not declaredeffect : <primitive> = external,E_DECLARATIONof kindeffect; and areadsorguardline that names a fact other than the six of v1, the collector's five and the derivedclean,E_DECLARATIONof kindreference(see Primitives and state); - a
jointable that fails a law,E_JOIN_LAW, whoseexpectednames the law:completefor a pair of distinct literals of its domain that it leaves out, its domain being the literal class of the value argument of the cell that names it,oncefor a pair it lists twice with different results,associative,idempotent, andclosedfor a pair or a result that names a literal outside its domain; each is reported once, whether two cells use the table or none, and a table that fails several laws gets one diagnostic, for the first law the reader finds, and a table that no cell names is checked foronce,associativeandidempotentover the literals it lists, and forcompleteandclosedonly once a cell names it (a table lists every unordered pair of distinct literals once, so it is commutative by construction, and the pair of a literal with itself is implicit, so idempotence holds by construction: such a pair need not be listed, a listed one whose result is its own literal is legal and ignored, and one whose result is another literal isE_JOIN_LAWwithexpectedidempotentand the diagonal's own literal, not the result, asactual); two cells that name one table but whose value arguments have different classes,E_DECLARATIONof kindconflictat the latercellline in position order within the declaration file; and astackingcell whose key's last component, its path, has a class that is neither the built-incanonical-pathnor a class the reader can show is a subset of it,E_KEY_CANONICAL(see Primitives and state); - an
eachthat would consume more elements than its declared fuel,E_RULE_FUEL, and acontextlookup with no enclosing program's term of the named constructor, or an argument thatscopemust resolve, one whose signature position is declaredrelative-path, or a class that is a bare reference to it, directly or through further bare references, with noworkdirterm in scope,E_CONTEXT(see Scope); - an
ensureinvariant that a plan's predicted state breaks,E_ENSURE(see Primitives and state).
Each kind of problem has one code. The registry lists every code, what it reports and the fields of data it carries (see Codes and the registry).
The reader reports every error it can find, not only the first. Every command that takes a declaration file, check, tree, plan, ask and emit, reads the declaration first and reports its diagnostics so. The errors are ordered by position, by file, line and column, and within one position in the order the reader detected them. A declaration is read whole, and all its errors are reported. A program is read only when its declaration has no diagnostic of severity error: check of a program under a failed declaration reports the declaration's diagnostics and exits with status 1 without reading the program. The one place where only a first failure is reported is the normalization of one term (see Failing checks).
After it reports a malformed line, the reader recovers: it goes on as if the line were well formed where the line has exactly one well-formed reading, and otherwise as if the line were absent: a malformed line with two or more well-formed readings is read as absent. A diagnostic that would exist only because of that recovery is not reported. So:
- a declaration file without the
#lang typifyheader reportsE_DECLARATIONof kindheader, then reads line 1 as an ordinary line; - a nested
declareline reports kindbodyonce, then opens a body of its own, closed by the nextend!, after which the enclosing body continues; - a malformed
ruleline still counts as the rule of its left side's constructor, which is therefore not reported unbound; - a form whose placeholder class is undeclared still binds its placeholder names, and its
doesline is checked against them.
A refused code point (see Refused code points) makes no line shapeless. The shape is read from the line's colon, arrow or bang, and the code point is refused by the class of the token it stands in, or by the forms when it stands in a verb or a literal.
A diagnostic holds nine fields:
| Field | What it holds |
|---|---|
code |
The code of the diagnostic's kind, from the registry. |
severity |
How serious it is: error or note. |
file |
The path of the file: the path as given for a file named on the command line, and the root-relative portable path for a program the tree located. A related entry's file follows the same rule. Paths use / on all four platforms, Windows included. E_USAGE, which names no file, carries the empty string "". E_REQUIRED carries the declaring file, the declaration file whose body holds the required! line, by its path as given on the command line; the missing program's path, or the template that locates nothing, is its data.path alone. |
range |
Where the problem starts and where it ends: a start and an exclusive end (see Ranges); null for E_REQUIRED, E_FILE and E_USAGE, which point at no position. |
message |
A sentence for a person. |
related |
Other places that bear on it, such as the line that declares a class. |
fix |
A replacement, when one is offered; no diagnostic of v1 offers one, and every diagnostic of v1 carries fix null. |
data |
The values involved, as typed fields. |
fingerprints |
An object of rule, verb, useOrdinal and primaryLocationLineHash (see Fingerprints). |
The data field holds the values the diagnostic is about, so a program that consumes diagnostics reads fields and never parses the message. The public corpus is compared the same way: a case's expected.json compares a diagnostic's code, file, range, and of data only the fields the registry lists for the code, and never its severity, message, fix or related (see Test your own host). A note is compared like an error, by the same four fields. A host may add fields; the comparison ignores them.
These are the native document's names. The SARIF projection renames the fields to SARIF's (see Other forms of a diagnostic).
A range has a start and an end. Each is a position with three members:
-
line, counted from 1; a line ends at a line feed (LF) or at a carriage return followed by a line feed (CRLF), and a lone carriage return ends no line and is a refused code point wherever it stands; -
column, counted from 1 in Unicode code points, not in bytes and not in UTF-16 units; -
byteOffset, the position's offset from the start of the file in bytes of UTF-8, counted from 0.
The end is exclusive: it is the position just after the last code point of the range. The range of a file's first code point, when that code point takes one byte, is:
{"start": {"line": 1, "column": 1, "byteOffset": 0}, "end": {"line": 1, "column": 2, "byteOffset": 1}}A case's expected.json compares this shape exactly.
What a diagnostic's range covers depends on its code:
| Code | The range covers |
|---|---|
E_LINE_SHAPE, E_FORM_NONE, E_QUESTION, E_ORDER, E_EXAMPLE
|
The whole line, from its first to its last non-blank code point. |
E_CLASS |
The token. |
E_CAP |
For the cap length, the token; for any other cap, the is line of the class that exceeds it, the cap line that raises a cap above its default, or the declare line when a cap is lowered below what the meta body's own classes need. |
E_CLASS_UNDECLARED, E_CLASS_OVERLAP, E_FORM_SHADOW
|
The declaring line whole: the is, form, term, rule, cell or cap line, or the offending line. |
E_KEY_CANONICAL |
The cell line whole, the cell being the subject of the defect. |
E_JOIN_LAW |
The table's first join line, whole; for a pair listed twice with different results, the second listing, whole. |
E_DECLARATION of kind header
|
Line 1. |
E_DECLARATION of kind body
|
The declare line of the unclosed body, the inner declare line of a nested body, or the line outside any body. |
E_DECLARATION of every other kind |
The declaring line whole, as for E_CLASS_UNDECLARED. |
| A failure to compile a class | The class's is line. |
N_CLASS_EMPTY |
The class's is line. |
N_CELL_WIDTH |
The cell's first writes line. |
E_RESTRICTS |
The restricts! line. |
E_TERM_CLASS, E_TERM_NESTED, E_CONSTRUCTOR_UNBOUND, E_RULE_DUPLICATE, E_RULE_CYCLE, E_RULE_FUEL
|
The term's own span within its does or rule line, never the line from its start. |
E_ENSURE, E_FACT_REJECT, E_CONTEXT
|
The program line whose term produced the step. |
E_LIBRARY_DOMAIN, E_LIBRARY_PARENT
|
The program line whose term produced the step, or, for a failing example, the library call in the form's does line. |
E_PROGRAM_COUNT |
A line of the program file: for an excess, the line of the first term past the multiplicity within its group (under an unkeyed count, the group is the whole program); for a missing count, the program's first line, or the empty range from line 1, column 1 to line 1, column 1 when the program is empty. |
E_REQUIRED, E_FILE, E_USAGE
|
Nothing: the range is null, since these diagnostics point at no position. |
A count failure stands in the program file, and its related carries the origins of the counted terms, defaulted terms included. Its data carries the constructor as constructor, the multiplicity as written as expected, a string such as "0..1", the number of terms in the group as actual, an integer, and the group's tuple as key, an array of decoded strings: the first k arguments shared by a keyed count's group, or the empty array, [], under an unkeyed count. A keyed count requires no group to exist, so it fails only by excess (see Terms and counts). A keyed count gives one diagnostic per failing group, each anchored as above within its program, and an unkeyed count's failure stands beside them, all in position order.
A cycle is reported once. The classes, or the constructors, that reach one another through references give one diagnostic, at the earliest declaring line among them in position order: for classes, E_DECLARATION of kind class-cycle covers that is line whole; for rules, E_RULE_CYCLE covers the left-side term of that rule.
Suppose the first line of catalog.typify is:
item : magazine = Weekly
The Catalog language (see Examples) declares is : category = "book" | "journal", so the capture magazine fails the class category. The capture is the exact text that the form's literals delimit, and the class decides. The diagnostic for that line, as one JSON document:
{
"code": "E_CLASS",
"severity": "error",
"file": "catalog.typify",
"range": {
"start": {"line": 1, "column": 8, "byteOffset": 7},
"end": {"line": 1, "column": 16, "byteOffset": 15}
},
"message": "magazine does not match class category",
"related": [
{
"file": "languages.typify",
"range": {
"start": {"line": 7, "column": 1, "byteOffset": 76},
"end": {"line": 7, "column": 35, "byteOffset": 110}
}
}
],
"fix": null,
"data": {
"class": "category",
"token": "magazine"
},
"fingerprints": {
"primaryLocationLineHash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
"rule": "E_CLASS",
"useOrdinal": 0,
"verb": ""
}
}The code E_CLASS and the members of data, class and token, are exact: they are what the registry lists for a token that fails its class (see Codes and the registry). The nine field names, the shape of range and the positions are exact too. The message's form and wording are illustrative, and the reader as released prints related empty for E_CLASS, so the entry shown illustrates the shape a host may attach; fix is null in every diagnostic of v1.
The positions, worked out:
-
itemfills columns 1 to 4, the space, the colon and the space fill columns 5 to 7, andmagazinefills columns 8 to 15. The range starts at column 8 and ends at column 16, the column after the capture, because the end is exclusive. - The capture starts at byte offset 7 and ends at byte offset 15: it is 8 bytes long. The byte offset is the column minus one here only because the capture sits on the file's first line and every code point before it and in it takes one byte.
- The related entry is line 7 of
languages.typify, theisline that declarescategory, and its range covers the whole line. The line is 34 code points long, so the range runs from column 1 to column 35. It starts 76 bytes into the file and ends at byte offset 110, each line of the file ending with a single line feed. -
fixholds no fix: no diagnostic of v1 offers one, and none carries near words, whichaskalone prints (see Questions).
typify check languages.typify Catalog catalog.typify exits with status 1, and, because the failing line builds no item term, also reports E_PROGRAM_COUNT for count : item = 1..* alongside the text projection of this diagnostic. With --json, the document above is a member of the diagnostics array of the result (see Exit status and JSON).
Every kind of diagnostic has a code, and the registry below holds every code of v1: thirty-one, twenty-nine of severity error and two, N_CLASS_EMPTY and N_CELL_WIDTH, of severity note. No diagnostic carries a code outside the registry. The third column lists the fields of data that a case's expected.json compares for that code, and only those; a host may add fields, which the comparison ignores.
| Code | What it reports | Data fields compared |
|---|---|---|
E_LINE_SHAPE |
A line that is none of the three shapes, or a colon line with an empty verb, a bang line with an empty verb, or an arrow line with an empty side. | actual |
E_FORM_NONE |
Any other line of one of the three shapes that no form takes. | actual |
E_FORM_SHADOW |
Forms that shadow each other, when the declaration is read. |
form (the shadowed form), actual (the shadowing form) |
E_CLASS |
A token that fails its class; a token longer than the length cap is E_CAP, never E_CLASS. |
class, token
|
E_CLASS_UNDECLARED |
A bare name in an is line that names no class. |
class |
E_CLASS_OVERLAP |
A class that can hold the literal that follows its placeholder in a form, or adjacent placeholders that cannot both capture. |
form, class, token (the literal the class can hold; for adjacent placeholders with no literal between them, class is the first placeholder's class and token is empty) |
E_CAP |
A cap exceeded. |
cap (the cap's name), limit (the configured limit), actual (the attempted count; for depth, the class's depth) |
E_EXAMPLE |
An example line that does not fit its form. |
form, actual
|
E_PROGRAM_COUNT |
A program that breaks a count, unkeyed or keyed; under a keyed count, one group of its terms past the multiplicity. |
constructor, expected (the multiplicity as written, a string), actual (the number of terms in the group, an integer), key (the group's tuple, an array of decoded strings, empty, [], under an unkeyed count) |
E_ORDER |
A program whose lines break order : strict. |
form, expected, actual
|
E_REQUIRED |
A required! program that is missing, or a required! template with a placeholder that locates nothing; no program is invented. |
path (the missing program's path, or, for such a template, the template; it appears in no other field, neither file nor related) |
E_TERM_CLASS |
An argument, or a library call's result, outside its receiving class. |
kind, constructor, class, actual
|
E_TERM_NESTED |
A nested user constructor at a string position. |
constructor, actual
|
E_CONSTRUCTOR_UNBOUND |
A constructor that is neither a primitive, nor rewritten by a rule, nor a fact, where it must be one of the three. | constructor |
E_RULE_DUPLICATE |
A duplicate rule: a second rule for one constructor. |
constructor, rule
|
E_RULE_CYCLE |
A rule cycle: constructors whose rules reach one another, reported once, at the earliest rule among them. |
constructor (the constructor of that rule) |
E_RULE_FUEL |
An each past its declared fuel; over a lookup, its related carries the origin of the first term past the cap. |
constructor, limit, actual
|
E_CONTEXT |
A (context <constructor>) with no enclosing program's term of that constructor, or, under scope, an argument whose signature position is declared relative-path, or a class that is a bare reference to it, directly or through further bare references, with no workdir term in scope. |
constructor, key (an array of decoded strings in key order, as a state entry's key: [] for the context case; for a relative-path argument with no workdir term in scope, the full tuple of the key the term writes, that argument as written among its components and never split at its slashes, when the argument is one of that key's components, and otherwise the one-element array of the argument as written, no cell key carried; a key component not yet evaluated when the diagnostic is raised stands as written, so the tuple keeps the cell's width, and one already evaluated carries its decoded string) |
E_LIBRARY_DOMAIN |
A library call outside its function's domain. |
constructor (the function), expected (its domain), actual (the string) |
E_LIBRARY_PARENT |
parent of /. |
path |
E_JOIN_LAW |
A join table that fails a law: it leaves out a pair of distinct literals of its domain, lists one pair twice with different results, is not associative, lists the pair of a literal with itself with another literal as its result, which breaks idempotence, or names in a pair or a result a literal outside its domain; reported once, whether two cells use the table or none. |
cell (the table's name), expected (the law: complete, once, associative, idempotent or closed), actual (decoded: the missing pair, the pair of the second listing, the triple, the diagonal's own literal, or the literal outside the domain) |
E_KEY_CANONICAL |
A stacking cell whose key's last component, its path, has a class that is not canonical: neither canonical-path nor a class the reader can show is a subset of it. |
cell, class
|
E_ENSURE |
An ensure invariant that fails. |
ensure, key (the key, an array of decoded strings in key order, as a state entry's key: one element at width one, [] when empty) |
E_FACT_REJECT |
An absent fact, read by a primitive whose reads line says reject. |
fact, key (the key, an array of decoded strings in key order, as a state entry's key: one element at width one, [] when empty) |
E_RESTRICTS |
A form marked restricts! whose constructor carries neither an unkeyed count = 1 nor an unkeyed count = 1..* nor a default line; a keyed count never satisfies it on its own, since it requires no group to exist. |
form, constructor
|
E_QUESTION |
A malformed ? line, such as one whose word fails the verb class. |
actual |
E_FILE |
A file that cannot be read, or cannot be read as what it must be, such as a facts file given with --facts that does not follow the facts wire, path being that file's; or, when facts, plan or tree runs the collector, a root or entry that could not be read, path being the root's or the entry's. |
path |
E_USAGE |
A misuse of the command line, such as an unknown command, an unknown flag, a flag whose argument is missing, or an asked word that the language does not declare and that fails the verb class. | actual |
E_DECLARATION |
A fault in a declaration's structure, named by kind. |
kind, actual
|
N_CLASS_EMPTY |
A note, not an error: a class whose language is empty once intersected with the allowed code points. | class |
N_CELL_WIDTH |
A note, not an error: a cell that, in a declaration file checked alone, has only delete writers, so its key width is not yet fixed. |
cell |
A note never changes the exit status, and a case's expected.json compares a note like an error, by its code, file, range and data.
For E_CLASS on the lines of a declaration, which the meta language reads, class names one of the meta body's classes: number (versions and caps), multiplicity (count values), prefix (the comment prefix), order-mode and ordering (strict or free), law (cell laws), width (write widths and the k of a keyed count), limit (states, repetition, depth or length), scope-mode (program, parent or root), name (the names of bodies, classes, constructors and cells; constructor is defined as name and reports as name), production, term, pattern, value (argument captures on example, term, primitive, file, default, writes, reads, ensure, join and guard lines), text (the text of a note line, any run of allowed code points) and verb (the verb class, of the question word), which E_CLASS never names: a question line whose word fails it is E_QUESTION.
A token longer than the length cap is E_CAP with cap length, never E_CLASS. For E_CAP, cap names one of the declared caps, states, repetition, depth or length (see Caps), or one of a host's own guards by its own name, such as temporary-states or reference-nodes. A host lists its own guards in its check --bounds report (see Command line), and no corpus case depends on one.
For E_TERM_CLASS, kind is one of literal, capture, result, arity and sort. For kind capture, actual is the name of the source class; a host that reports a counterexample puts it in a field of its own, which the comparison ignores.
For E_DECLARATION, kind is one of these thirteen:
kind |
What it reports |
|---|---|
header |
A malformed #lang line. |
body |
An unclosed or nested body, or, outside any body, a line that is not a question line. The reader of a declaration passes over a well-spelled question line, inside or outside a body, and one whose word fails the verb class is E_QUESTION (see Questions). |
duplicate |
A declaration or a property declared twice; a second unkeyed or a second keyed count for one constructor, a count line written with by 0 being the unkeyed form; a second file line in one body; a second restricts! line under one form; a placeholder name repeated within one form (two placeholders of one class take distinct names, each referring to the class through a reference), or within one file template; a form placeholder or a rule variable that has the name of a placeholder of its language's file template (see Template placeholders in terms); or a class, term, primitive or cell declared under the name of a library function (parent, join, split, ancestors, prefix, suffix, equal, concat, inherited), a built-in class (letter, canonical-path, relative-path) or any of the 17 meta classes (named under E_CLASS above): no class, term, primitive or cell shadows one of these names, and a form's verb, which is none of these, may be spelled letter, canonical-path or relative-path (see Questions). A form with the verb ? in any body but the meta body, which alone declares that verb, has this kind, with ? as actual, and so does a body declared Typify, the meta body's name, with Typify as actual, unless the declaration file's text is the reader's own meta source, byte for byte, which is the meta body itself (see Questions). |
orphan |
A does, example, default or restricts! line with no form above it. |
arity |
A rule's left side with the wrong number of variables for its constructor's signature, or a constructor of more than one argument named under (context ...) or (inherited ...), which is never truncated to its first argument, with the constructor as named as actual. A term with the wrong number of arguments at a use, in a does line or on a rule's right side, is E_TERM_CLASS of kind arity instead. A bare reads or guard on a partitioned cell whose key has more than one component after the partition, for a fact of one argument, has this kind too, on that reads or guard line, which must then be a parenthesized call. |
capture |
A placeholder whose class is undeclared. |
syntax |
A malformed class, pattern, term or rule, a host predicate, or a form without a does. A cap of zero is syntax: every cap is positive. An (if ...) whose fact is a bare name, not a parenthesized fact call with its arguments, is syntax too. So is a keyed count whose k exceeds the number of arguments of its constructor's signature, with the count line whole as actual, and a default line whose form's does term uses a template placeholder, since a default line's arguments are literal text (text such as <name> in a default line is read as literal text and fails with E_EXAMPLE when its class rejects it). A state predicate inside (if ...), and covered or uncovered on a cell that is not stacking, are syntax as well, on the rule or ensure line whole. A nullary constructor is declared term : ready or primitive : ready, without a trailing colon; a trailing colon is syntax. |
class-cycle |
Classes that reach one another through references, reported once, at the earliest is line among them. |
stratification |
A right side that uses a constructor declared later than its left side's. A rule on a rule cycle whose right side names a constructor declared later has this kind too, reported separately from the cycle's E_RULE_CYCLE. |
reference |
An undeclared language, constructor, count target, fact or cell, or a reads or guard line that names a fact other than the six of v1: the collector's five, exists, directory, symlink, mode and owner, and clean, which the reader derives from the facts file. A (context ...) or (inherited ...) that names an undeclared constructor has this kind, found when the declaration is read, and so does a cell line that names an undeclared join table. Both lookups take a qualified name, Language.constructor; a bare name is resolved when the declaration is read, against the composition, the set of bodies of the declaration file, in the one-program forms as under a root: it is accepted when exactly one body declares it, and is otherwise of this kind, with the name as actual and the declaring bodies in related, refused by tree, plan, ask and emit as by check, since every command reads the declaration first and reports its diagnostics as Every error, in order says. At plan, a cell that has no put writer in the root's composed languages; a declaration file checked alone whose cell has only delete writers passes check with the note N_CELL_WIDTH. |
conflict |
A constructor declared both fact and effect, or both primitive and rewritten; a writes that puts with a width other than its cell's key width, or that deletes with a width greater than the key width (a delete of width k from 0 to the key width matches), the key width being fixed by the cell's first put writer, resolved in the declaration order of the languages, then in line order, never in tree order; or two cells of one name among a root's languages that disagree on the class of a key component, or on their law, stacking, key width or join table, since cell names are global across a root's languages, a component's classes agreeing when they are the same built-in class in both cells, or a declared class of one name whose expression is identical as written in both bodies; or two cells that name one join table but whose value arguments have different classes, at the later cell line in position order within the declaration file, since a table's domain is the literal class of the value argument of the cell that names it; or default lines for one constructor that would by themselves exceed the constructor's multiplicity, or, under a keyed count, a group's multiplicity, refused when the declaration is read, so that no program ever reports a count failure produced by defaults alone. |
effect |
A primitive that has no writes line and is not declared effect : <primitive> = external, a primitive declared effect : <primitive> = state without a writes line included. |
partition |
A term that writes a partitioned cell without its partition. A program located by a file template writes only partitioned cells, a stacking cell or any other: every put or delete from it carries all the placeholders of the template, in template order, as the leading components of the key, which on a stacking cell are all its earlier components, so a language with a file line has no unpartitioned write. Each such component of a put or delete term is a placeholder of that template; a put with fewer components, or any other value in those places (such as a does or rule line building bind under file : teams/<team>/shares.typify and writes : bind : mounts = put 1), has this kind, reported when the declaration is read, on the does or rule line whole whose term supplies the components, with the term as written as actual. When a writes line's put width is smaller than the number of template placeholders (as writes : bind : mounts = put 1 is under file : teams/<team>/<kind>/shares.typify), or when a delete k has k below the number of partition components, delete 0 included, it has this kind at the writes line whole, with the line as written as actual: on a partitioned cell a delete names at least its partition components, and delete 0 clears the whole cell only on a cell that is not partitioned. A template without placeholders supplies no component, and its writes are unchanged. See Stacking cells. |
The values in data follow fixed conventions, so that every host and the corpus write the same:
-
E_DECLARATIONcarries inactual: forheader, the first line, as the next item states; forbody,EOFfor an unclosed body, the innerdeclareline as written for a nested body, and the line as written for a line outside any body; forduplicate, the duplicated name, property or clause, a secondcountline of one kind, unkeyed or keyed, as written, the repeated placeholder as written with its angle brackets, a form placeholder or a rule variable named like a template placeholder, as written with its angle brackets, such as<shelf>, or the declared name that is already a library function's, a built-in class's or a meta class's; fororphanandsyntax, the line, as the next item states; forarity, the rule's left side as written, or, for a constructor under(context ...)or(inherited ...), the constructor as named; forclass-cycle, the class that the cycle's earliestisline declares, as a string; forcapture, the placeholder as written, angle brackets included, such as<price>; forconflictfromdefaultlines, the firstdefaultline past the multiplicity, or past a group's multiplicity under a keyed count; forreferencefrom a bare name under a lookup, the name; forpartition, the term as written that supplies the components, or, for aputwhose width omits the template's placeholders and for adeletethat names fewer than the partition components, thewritesline as written. - Where
actualcarries a line rather than a name or a term, forE_LINE_SHAPE,E_FORM_NONE,E_QUESTIONandE_DECLARATIONof kindsheader,body,orphanandsyntax, and of kindpartitionfor adeletethat names fewer than the partition components, it carries exactly the text the range covers. For kindbodythat is the nesteddeclareline and the line outside any body; an unclosed body keepsEOFasactual, as the previous item says. For the kinds whose range is the declaring line whole, that is the line from its first to its last non-blank code point with its introducer, such asis : num = /(?=a)[a-z]+/,form : orphan : <word>orrule : action "literal" -> prim "literal"; forE_LINE_SHAPE, it is the line stripped of its outer blanks. - The
formandrulefields carry the production after theform :orrule :introducer, such asaction <x> -> prim <x> ; prim <x>for a rule, asE_FORM_SHADOW'sformandactualdo. -
E_CAPwithcapdepthcarries the cap aslimitand the class's depth asactual(see Caps). -
E_TERM_NESTEDcarries the receiving constructor asconstructorand the nested term as written asactual. -
E_ORDERcarries asexpectedthe smallest permitted ordinal of the prior form and asactualthe current form's ordinal, both counted from zero in declaration order. -
E_TERM_CLASSof kindarity, a term with the wrong number of arguments at a use, in adoesline or on a rule's right side, covers the term's own span and carries the signature asclassand the number of arguments received asactual; of kindsort,actualisstring,listorpredicate. -
E_FORM_SHADOWcarries the later, shadowed form asformand the earlier, shadowing one asactual. -
E_JOIN_LAWcarries the law asexpected, one ofcomplete,once,associative,idempotentandclosed, and asactualthe values involved, decoded as a quoted literal is read in a term (see How a term is written): forcompletethe missing pair, foroncethe pair of the second listing, forassociativethe triple, foridempotentthe diagonal's own literal, the literal of a listed pair of a literal with itself, not the result it gives, and forclosedthe literal outside the domain. A pair or a triple is its decoded literals separated by one space, never the quoted lexeme. An authored pair keeps authored order: the pair ofjoin : modes : "ro" "rw" = "rw"is theactualro rw. Where nothing authored a pair or a triple, the missing pair forcompleteor the triple forassociative, its literals come in the order of the value class's literals; for a table that no cell names, an unauthored triple lists its literals in the order of their first appearance in the table'sjoinlines, each line read left to right, its result included. -
E_USAGEcarriesfile""andrangenull, and asactualthe offending token as written, such as an unknown command's word, an unknown flag, the flag whose argument is missing,--factswhen the declaration reads a fact and the one-programplan, which has no root to collect from, is given no--facts, or, in the one-program forms ofcheckandplan, the program's path as given when it does not match its language'sfiletemplate, or--gbnfwhenemitis given it with--json, or a word given toaskthat the asked language does not declare and that fails the verb class, never the whole command line; a root that the collector reads (typify facts ROOT, or atreeorplanthat needs a fact) and that is not acanonical-pathafter lexical normalization isE_USAGEwith the root as supplied asactual(a symbolic-link root isE_FILE). A usage error, an unknown command included, prints{"ok": false, "diagnostics": [...]}when--jsonis among the arguments, and the text projection otherwise; the exit status is 2.
A diagnostic's data holds the values its message names, under these keys where they apply: form, class, token, constructor, expected, actual, rule, cell, key, fact, ensure, cap, limit and path, and kind for E_TERM_CLASS and E_DECLARATION.
Before 1.0.0 a code may be renamed freely. From the first tag on, each release compares the registry with the one at the previous release, a commit the release workflow pins: a removed or renamed code fails the release. New codes may appear. A released code does not disappear or change its name, so a tool can match on it.
A fingerprint attaches stable location metadata to a diagnostic. In the native JSON document it is the member fingerprints, an object of rule, verb, useOrdinal and primaryLocationLineHash (also carried in the SARIF and LSP projections; in 1.0.0 verb is "" and useOrdinal is 0 when no form-use site is recorded, and primaryLocationLineHash hashes any recorded source snippet or the empty string).
A check that fails, an ensure invariant for example, carries three things in its diagnostic: its name, its data, and the origins of the terms it joins, which are the program lines those terms came from. The Mounts language (see Rules and plans) masks a path's parent before it binds the path. If its rule bound the path first, the mask would put at the ancestor after the put at the child in the stacking cell mounts, the child would not be visible, and the invariant child-visible would fail on the predicted state. The rules alone accept that order; the invariant rejects it. Its diagnostic, E_ENSURE, would carry the name child-visible, its data, and line 1 of the program as the origin of the terms it joins.
When a term fails to normalize, the reader reports that term's first failure in normalization order: left to right, innermost first. This first-failure rule governs the normalization of one term only; across its files the reader reports every error it can find (see Every error, in order). parent of / is one such failure: the root / is a path with zero components and has no parent, so the call is an error, E_LIBRARY_PARENT. A call outside its function's domain is another: parent, split and ancestors, and the first argument of join, take a canonical-path, the root included, and refuse any other string with the code E_LIBRARY_DOMAIN; join also refuses a second argument outside its domain (see Library functions). Outside the domain is an error, never a host default.
The text form, SARIF, LSP and GitHub annotations are projections of the native document: each is computed from it, and the reader prints the last three with --sarif, --lsp and --github-annotations, one flag per command. In text mode the reader prints each diagnostic as its text projection, and check prints diagnostics only, nothing when there is no diagnostic; a note is printed although the exit status stays 0.
The SARIF projection renames the fields to SARIF's, such as ruleId for code, level for severity, region for range and properties for data.
Converting a diagnostic to SARIF or to LSP keeps its range equal: the converted range covers the same code points, including on lines with characters outside the Basic Multilingual Plane.
An LSP position is a zero-based line and a zero-based character, and the character counts UTF-16 code units. An LSP range has a start and an end, and its end is exclusive, as the native one is. Each end of a native range converts the same way:
- the LSP line is the native
lineminus one; - the LSP character is the number of UTF-16 code units taken by the code points that come before the position on its line. A code point from U+0000 to U+FFFF takes one unit; a code point above U+FFFF takes two.
The end stays exclusive. The byte offset has no part in an LSP position.
In the example above every code point before the capture and in it takes one unit, so the character is the column minus one. The range of magazine converts to:
{"start": {"line": 0, "character": 7}, "end": {"line": 0, "character": 15}}On a line that holds a code point above U+FFFF the two counts part. Suppose the first line of catalog.typify is instead:
item : 𝐁ook = Algebra
Its first capture begins with U+1D401 MATHEMATICAL BOLD CAPITAL B, a letter outside the Basic Multilingual Plane: one code point, four bytes of UTF-8 and two UTF-16 code units. The capture 𝐁ook fails the class category. Its native range starts at line 1, column 8, byte offset 7 and ends at line 1, column 12, byte offset 14: four code points and seven bytes. Its LSP range starts at line 0, character 7 and ends at line 0, character 12, because the capture takes five UTF-16 code units:
{"start": {"line": 0, "character": 7}, "end": {"line": 0, "character": 12}}The column minus one would give 11 for the end, which would cut the capture short. Both ranges cover the same four code points.
| Exit status | Meaning |
|---|---|
0 |
Clean. |
1 |
Errors were found. |
2 |
A usage error, E_USAGE, or a file that could not be read, or not as what it must be, E_FILE. |
Notes never change the exit status: a run whose only diagnostics are notes, such as N_CLASS_EMPTY, exits with status 0.
The commands check, tree, plan, ask and emit each take --json, which puts the command's result on standard output as one JSON document (see Command line). emit prints the grammar alone, a document and not a report: the JSON grammar under --json or by default, the GBNF text under --gbnf, never with a diagnostics key and never with a note, which check reports. On a failed declaration emit prints {"ok": false, "diagnostics": [...]} under --json, and the text projection otherwise, and exits with status 1, as check does.
The result of check --json carries the diagnostics in its diagnostics array, each one the native document. The objects that tree and plan print with --json carry the same array: each of these commands prints its own object in every outcome, and the array is empty when nothing is reported. ask prints its answer object, whose diagnostics carries what reading the declaration reports, notes included, or, on a failed declaration, an unreadable file or a word that fails the verb class, {"ok": false, "diagnostics": [...]} with no answer fields (see Command line). For the clean Catalog program item : journal = Market Research, typify check languages.typify Catalog catalog.typify --json prints an object whose diagnostics array is empty:
{"ok": true, "terms": [["item", "journal", "Market Research"]], "diagnostics": []}When the program form is run and the declaration has rules, the result also has a bound member.