Rule 12.6
On this page

Rule 12.6

Chapter 12, Diagnostics Test

A requirement the front end can check must be checked at the front end, in the author’s words, and not left to Tint or a driver.

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

Rationale

WGSL checks each requirement at the earliest opportunity, and for TypeShade the earliest opportunity is the source line.

Derives from

Errors (“each requirement will be checked at the earliest opportunity”); surface §3 and §7.

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:

TS8029, TS8031, TS8036, TS8038, TS8068, and the rest of the front-end codes, among them TS8002 for a type the file declares nowhere, which used to be emitted as a struct of that name for Tint to refuse (src/compiler/ts/unknown-names.test.ts); the requirements proposal 0008 moved forward from Tint: a for update the lowering does not count, refused instead of dropped with its loop (Rule 7.5), an operator WGSL has no overload for on its operands’ kind (Rule 7.1), a vector of bools in a uniform or storage binding (Rule 6.8), a decorator nothing reads, @group and @binding on a declaration among them (Rule 6.7), a barrier, a derivative or a workgroupUniformLoad after a non-uniform break or continue (Rule 8.5), and a while condition that is not a bool (Rule 7.5), each pinned where that rule’s Enforced-by names it, and a loop’s hidden counter, which an author’s _w or _i reached (Rule 2.2), pinned by src/compiler/ts/loop-shapes.test.ts; two constant expressions Tint refused, now folded as a divisor is and refused with TS8003: a clamp whose bounds cross (src/compiler/ts/clamp-bounds.test.ts, #373) and an f32 value past the range (src/compiler/ts/f32-const-range.test.ts, #374); the debts of Appendix B are the requirements not yet moved forward.

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:

TS8002 UNKNOWN_TYPE
A type name nothing declares, said once for the file wherever it is written (a parameter, a claim, a type argument, B<vec3<Foo>> included, an alias, an implements clause, the base a class or an interface extends, a body no call lowers), a type the library declares for TypeScript alone (Number) where the file declares none of its name, or a type this surface does not take in a position the mapper reads (Rule 2.1).
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.
TS8029 STRUCT_FIELD_MISSING_ATTR
A field of a struct used as an entry function's parameter or return type carries neither @builtin(...) nor @location(...): WGSL rejects an entry-IO struct member with no attribute, so this is caught at the front end instead of reaching the backend as invalid emitted WGSL.
TS8031 RECURSION
A call cycle: a function that reaches itself, directly or through other functions.
TS8036 MATH_ARGUMENT
A math builtin called with arguments its signature does not take: two shapes that had to agree (dot(vec3, vec2), clamp(v, 0., 1.) with a vector v), an element kind the builtin has no form for (sin on an integer vector, mix on one), a scalar where a vector is due (normalize(s), cross on a vec2), mix's factor or refract's eta of the wrong shape, ldexp's exponent not an i32 of x's shape, a bit offset or count that is not a u32, or transpose/determinant on a non-matrix.
TS8038 F64_ENTRY_IO
An emulated double (f64, a vec64) on an entry's IO boundary — a @location parameter, a @location field of an IO struct, or an entry's return.
TS8068 RESERVED_NAME
A declared name that a target reserves, checked on the name the emit actually carries: half as a struct field, which ANGLE answers with "Illegal use of reserved word" in generated text the author never wrote.

See also

Source

The rule at commit 26de7be8:

Edit this page Report a problem