Rule 12.1
Chapter 12, Diagnostics Test
A diagnostic must name the offending thing and the remedy in at most two sentences: the first states the mistake, and the second, when there is one, states the remedy or the reason.
For a name the compiler cannot find (a value, a callee, a type, a field, a member, an assignment target, an attribute, a @builtin id, an extension, an import), the remedy is chosen in one order at every place a name is written: TypeShade’s spelling of a GLSL or HLSL name; else the name of the same kind that exists at that place and is spelled like it, by TypeScript’s own spelling rule with a swap of two adjacent letters counted as one edit (“Did you mean “clamp”?”); else the place’s own remedy. The span is the name itself.
The rule text and the parts under it are the compiler's own English, as the design document writes them.
Rationale
an author reads it against the line they wrote, and a third sentence is where the remedy gets lost.
Derives from
Diagnostics; surface §7 and §28 (“one mistake reads as one sentence”); the pinned sentences of the refusal tests under src/compiler/ts/ (TS8031 Recursive call: "a" -> "b" -> "a". WGSL has no call stack, so a function must not take part in a call cycle.), which have that shape.
How it is verified
Checked by a test. A test, a gate script or a CI workflow names this rule, and the traceability check fails when a file listed below stops naming it.
Where the rule says the compiler enforces it:
every refusal test asserts the code and the message text (Rule 12.5). A GLSL or HLSL name the compiler refuses names TypeShade’s spelling as its remedy rather than “declare it in this file” (lerp is mix, gl_FragCoord a @builtin("position") parameter), from FOREIGN_NAMES in src/compiler/ts/foreign-names.ts, in src/compiler/ts/foreign-names.test.ts (#218); no name is added (Rules 2.1 and 9.6), and the table’s targets are checked against the ambient library (Rule 12.7). The order for an unknown name is unknownNameRemedy in src/compiler/ts/unknown-names.ts, pinned at each place a name is written by src/compiler/ts/unknown-names.test.ts; that the compiler names every name TypeScript would suggest for a misspelling is src/language-service/editor-parity.test.ts.
The files that verify it at commit 26de7be8, each at the first line that names the rule:
Explained in
The sections of the surface document that explain this rule, at commit 26de7be8:
See also
Source
The rule at commit 26de7be8:
docs/language-design.md:1225(the design document)reqs/rules/RULE-1201.md(its traceability item)