The Nish language

This is the normative reference for Nish, the subset of TypeScript that nish compiles to LLVM IR. It describes what the compiler accepts today, what each construct means, and how every rejection is worded. The design notes (docs/wp*.md) explain why; this page says what.

Nish is 0.x, and 1.0 has no date. Until then any minor release may change the language: a change that withdraws or narrows an accepted construct, or changes what one means, is marked breaking (type!) and named in the release notes. From 1.0 the rule tightens: a minor may add a rule or turn a refusal into an acceptance, and anything else needs a major. In either case the wording of a refusal may change in any release, but its diagnostic code may not, because --json consumers key on it. Where the compiler disagrees with this page, the compiler is wrong, and fixing it is not a change to the language.

Conventions:

  • Every rule cites a test case in parentheses, e.g. (tests/cases/cf_if), meaning tests/cases/cf_if.ts (with its .ll golden, .out native output, or .err expected message). A tests/link/<name> citation is a whole-program link test. Rules marked (CLI only) were verified by compiling a snippet with nish and have no dedicated test case yet.
  • Error messages are quoted as the fragment tests/run.js matches; the full line is <file>:<line>:<col>: error: <message> followed by a caret excerpt (wp10-ci.md).
  • "i32 mode" is the default; "f64 mode" is --number-mode f64. Everything else is mode-independent unless stated.
  • The exact IR for each construct is in IR_COOKBOOK.md.

Contents: Lexical rules · Types · Nullable types · Result and error handling · Declarations · Statements · Expressions · Builtins · Map and Set · Capabilities · Semantics decisions · Memory model · Forbidden constructs · Rejected by the checker · Known inconsistencies