Wit

The spec

The normative description of Wit 0.3 is docs/spec.md in the repository. It is also a test suite: every example in it is built and compared with its expected output on every test run.

How it is checked

  • Each wit example followed by an html expected, md expected or text expected-error block is run by tests/runner/spec.test.ts. An error block names a code, optionally with at L:C.
  • Edge cases that would clutter the text live in tests/spec/ as case.wit plus case.expected.html, .expected.md or .expected-error; a folder with main.wit is a multi-file case.
  • tests/spec/pending.txt lists cases not implemented yet. They must still fail; one that starts passing fails the run until its line is deleted.
  • Expected HTML is compared without the <article class="wit-doc"> wrapper, ignoring whitespace between tags and just inside block tags.

The run prints N of M cases pass.

What it covers

Lexical structure, the prose layer, nodes and parameters, the parenthesis form, closing rules, definitions and headers, records, collections, data access, conditionals, iteration, scripting, composition, the core vocabulary, tables, scalars, the removed 0.2 forms, the error-code table, the AST kinds and the CLI.

Where to look

Sources of truth
QuestionLook in
what the language meansdocs/spec.md
one edge casetests/spec/
every page renders as beforetests/rendered/ snapshots
AST typespackages/parser/src/ast.ts
an error codepackages/parser/src/errors.ts and packages/runtime/src/errors.ts

These docs follow the spec. Where a page and the spec disagree, the spec wins — please report the page.

Adding to it

Write the spec case first, add it to pending.txt, implement, then delete the pending line. See Extending.

See also

Syntax reference · Errors · Changelog.