Rule 9.2
On this page

Rule 9.2

Chapter 9, Built-in functions and the TypeShade extensions Test

A builtin’s signature must be WGSL’s, checked at the call. The two recorded exceptions are atan(y, x) (WGSL’s atan2) and the ECMAScript arity of the Math members. A name of the f64 family, which has no WGSL signature, must take the signatures WGSL gives the type it stands in for (f64(x) as f32(x), vecNf64 as WGSL’s vector constructors), and a further signature of one is a new name under Rule 2.2.

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

Rationale

an argument shape Tint refuses should be refused at the source line, with the splat or the cast to write; and a signature is a spelling, so an overload that no WGSL form has is a spelling from nowhere (§2.1).

Derives from

Numeric Built-in Functions; Value Constructor Built-in Functions for the scalar and vector constructor forms; surface §10 (#57), §39.

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:

TS8036 MATH_ARGUMENT and src/compiler/ts/lower/math-args.ts, whose rule for a name with SUPPORTED core.def rows is derived from those rows (0017); TS8019 for f64(a, b) (f64() expects 1 argument.) and surface-names.test.ts (the f64 family declares only the constructor forms WGSL gives the type it stands in for, the compiler refuses a second argument to f64).

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:

TS8019 ARITY_MISMATCH
Wrong number of arguments, elements, or fields at a call or constructor site.
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.

See also

Source

The rule at commit 26de7be8:

Edit this page Report a problem