TS8036
On this page

TS8036

Front-end code 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.

The registry text and every compiler message on these pages are the compiler's own English.

When it fires

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. Named on the offending argument with the fix where one is short: splat the scalar, cast one side, give the vectors one size.

Example

example.shade.ts
"use typeshade"
@fragment
export function main(@location(0) uv: vec2): vec4 {
const n = vec3(0., 0., 1.)
return vec4(uv, dot(n, uv), 1.)
}

Compiled at build time against the pinned compiler, this program gets:

TS8036 error, line 6: dot takes arguments of one type; the first is vec3, this one vec2. Give the vectors one size.

How to fix it

The same program, corrected. It compiles with no diagnostic.

example.shade.ts
"use typeshade"
@fragment
export function main(@location(0) uv: vec2): vec4 {
const n = vec3(0., 0., 1.)
return vec4(uv, dot(n, vec3(uv, 1.)), 1.)
}

The rules this enforces

Rule 9.2 Test
A builtin’s signature must be WGSL’s, checked at the call.
Rule 12.6 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.

See also

Source

Where the compiler raises this code at commit 26de7be8, one line per file:

Edit this page Report a problem