---
title: "Rule 12.1: Diagnostics, a TypeShade design rule"
description: "Rule 12.1 of the TypeShade language design, in Diagnostics. A diagnostic must name the offending thing and the remedy in at most two sentences…"
url: https://typeshade.dev/reference/rules/12-1/
language: en
---

# 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 built-in value’s 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](https://gpuweb.github.io/gpuweb/wgsl/#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](https://typeshade.dev/reference/rules/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](https://github.com/typeshade/typeshade/issues/218)); no name is added ([Rules 2.1](https://typeshade.dev/reference/rules/2-1/) and [9.6](https://typeshade.dev/reference/rules/9-6/)), and the table’s targets are checked against the ambient library ([Rule 12.7](https://typeshade.dev/reference/rules/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 af54ddad5, each at the first line that names the rule:

- [`src/compiler/ts/array-minmax-types.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/array-minmax-types.test.ts#L1)
- [`src/compiler/ts/foreign-names.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/foreign-names.test.ts#L1)
- [`src/compiler/ts/foreign-names.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/foreign-names.ts#L1)
- [`src/compiler/ts/honest-refusals-tuples.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/honest-refusals-tuples.test.ts#L1)
- [`src/compiler/ts/honest-refusals.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/honest-refusals.test.ts#L1)
- [`src/compiler/ts/io-name-cascades.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/io-name-cascades.test.ts#L1)
- [`src/compiler/ts/static-read-wording.test.ts:2`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/static-read-wording.test.ts#L2)
- [`src/compiler/ts/unknown-names.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/unknown-names.test.ts#L1)
- [`src/compiler/ts/unknown-names.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/unknown-names.ts#L1)
- [`src/language-service/editor-parity.test.ts:2`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/language-service/editor-parity.test.ts#L2)

## Explained in

The sections of the surface document that explain this rule, at commit af54ddad5:

- [§7 Diagnostics (required)](https://github.com/typeshade/typeshade/blob/af54ddad5/docs/use-typeshade-surface.md#7-diagnostics-required)

## See also

- [Rule 11.27](https://typeshade.dev/reference/rules/11-27/) Test
- [Rule 12.2](https://typeshade.dev/reference/rules/12-2/) Review
- [Rule 2.1](https://typeshade.dev/reference/rules/2-1/)
- [Rule 9.6](https://typeshade.dev/reference/rules/9-6/)
- [Rule 12.5](https://typeshade.dev/reference/rules/12-5/)
- [Rule 12.7](https://typeshade.dev/reference/rules/12-7/)
- [Design rules](https://typeshade.dev/reference/rules/)
- [Error codes](https://typeshade.dev/reference/errors/)

## Source

The rule at commit af54ddad5:

- [`docs/language-design.md:1723`](https://github.com/typeshade/typeshade/blob/af54ddad5/docs/language-design.md#L1723) (the design document)
- [`reqs/rules/RULE-1201.md`](https://github.com/typeshade/typeshade/blob/af54ddad5/reqs/rules/RULE-1201.md) (its traceability item)
