Rule 2.3
On this page

Rule 2.3

Chapter 2, Sources of the surface Test

A value sometimes has to cross between a representation the compiler chose and one the target has: an f64 and the two f32 halves that carry it across an interface of f32. The compiler must either perform the bridge silently or refuse the program in one sentence naming an ordinary remedy. A spelling of the bridge, under any name, must not be a third option.

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

Rationale

the two honest answers to “the target cannot take this as written” are to make it work or to say what to write instead; a third spelling the author has to learn is neither.

Derives from

the same section of PR #166; the roadmap’s first rule, “ordinary TypeScript first”.

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:

  • TS8038 F64_ENTRY_IO (src/compiler/ts/lower/function.ts, PR #166) for an f64 on an entry’s @location parameter, on an entry I/O struct field, or on an entry’s return, one sentence that names f32(x) and the uniform or storage binding as the two remedies (surface §39), pinned by src/compiler/ts/f64-types.test.ts;
  • a TS8003 that names no remedy, for an f64 passed, returned, or assigned where an f32 is declared (Appendix B);
  • the surface-names test, which catches a spelling of the bridge that is a pre-emit id, a second signature of f64, or a non-constructor signature of a vecNf64, and the front end, which refuses a call of one;
  • review, for a spelling under a new id, which none of the cases above catches.

The files that verify it at commit af54ddad5, each at the first line that names the rule:

Explained in

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

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), a read of an optional value (T | undefined, T | null or T | null | undefined) that no test narrowed (Rule 7.10), or a constant the compiler folds that WGSL refuses: a shift amount past 31, a divisor of 0, clamp bounds that cross, an f32 past its range or a builtin call outside its domain, such as Math.pow(-2., 2.).
TS8038 F64_ENTRY_IO
An emulated double (f64 or a vec64) on an entry's IO boundary: a @location parameter, a @location field of an IO struct or an entry's return. A double is a pair of f32 words after lowering, and a varying interpolates each word on its own. Narrow with f32(x), or read the double in the stage that needs it, since a uniform or a storage binding carries an f64.

See also

Source

The rule at commit af54ddad5:

Edit this page Report a problem