TS8036
On this page

TS8036

Front-end code MATH_ARGUMENT

A math builtin called with arguments that its signature does not take: two shapes that had to agree (dot(vec3, vec2)), an element kind that the builtin has no form for (sin on an integer vector), a scalar where a vector is due (normalize(s)), or a factor, exponent, offset or count of the wrong type. The message names the offending argument and, where one is short, the fix: splat the scalar, cast one side, or give the vectors one size.

The registry has no documentation comment for this constant, so the line above is written by this site from the messages the compiler raises it with.

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

Example

example.shade.ts
"use typeshade"
@fragment
export function main(uv: location<0, 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(uv: location<0, 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 af54ddad5, one line per file:

Edit this page Report a problem