Rule 6.3
On this page

Rule 6.3

Chapter 6, Declarations and resources Test

A top-level const is a module constant: a scalar must fold to one value carried at double precision for the oracle and at the target’s precision for emit, and a vector, array, or struct must carry a constant-foldable expression every backend evaluates.

The rule text and the parts under it are the compiler's own English, as the design document writes them.

Rationale

a module constant must be one value on every backend, and the dual-precision scalar is how the oracle stays exact where the target rounds.

Derives from

Value Declarations (const); AGENTS.md (“module constants are scalar dual-precision by default”); surface §12.

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:

src/compiler/ts/module-const.ts and module-const.test.ts; a bool constant is true, false, 1, or 0 (TS8003, Module const "K" is bool, but 2 is neither true nor false. Write true, false, 1 or 0., pinned by rejects a bool module const that is neither true nor false).

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:

Error codes that enforce it

The diagnostic codes the rule names under Enforced by, or whose registry text names the rule:

TS8003 TYPE_MISMATCH
Two types that do not fit where they meet (an operator, a condition, a declaration, a return or an argument), or a constant the compiler folds that WGSL refuses: a shift amount past 31, a divisor of 0, clamp bounds that cross or an f32 past its range.

See also

Source

The rule at commit 26de7be8:

Edit this page Report a problem