Error codes
On this page

Error codes

92 codes

Every code the compiler puts on a diagnostic, read from its two registries at commit af54ddad5. The "use typeshade" front end has 51 codes and the core IR layer under it has 36.

51 pages carry a program that raises the code and the same program fixed. Both are compiled at build time against the pinned compiler, and the build stops when a program no longer raises its code or a fix no longer compiles clean. A row with an Example tag is one of them.

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

Front-end codes

The TS80xx codes, from TS_CODES in the front end. A "use typeshade" file is checked against these before any IR is built.

The file

TS8001 MISSING_DIRECTIVE Example
A file compiled as TypeShade that has no "use typeshade" directive at all.
TS8013 HOST_STMT Example
Host control flow and JavaScript runtime forms that no shader has: await, yield, an async or generator function, try/catch/throw, for…in, var, a spread outside an object literal and a template string. A new is a class rule, CLASS_MEMBER.
TS8014 TOP_LEVEL Example
Something at the top level of the file the compiler cannot declare: a bare statement, or a module-level declaration of a shape it refuses.
TS8030 SYNTAX Example
A TypeScript parse error in a "use typeshade" file, such as an unclosed parenthesis, a missing brace or an unexpected token. The file is not lowered or emitted. The language service shows TypeScript's own syntactic diagnostic in its place.
TS8050 ENABLE_NAME Example
A file-level "enable <extension>"; directive that names an extension outside the vocabulary of the WGSL backend's capability profile. A misspelled name would otherwise be an ordinary string statement and silently enable nothing.
TS8072 IMPORT Example
An import that the compiler does not follow (Rule 3.9): a path that names no file or one that this compile cannot read, a file that is not a shader module, a package that no node_modules holds, a subpath that a package's exports does not name, a name that the module does not export, or a form that a shader module has no use for (a default import or export, an import that names nothing, import(...), require).
TS8099 UNSUPPORTED Example
The catch-all for a diagnostic whose site does not yet deserve its own code. It stays parked at TS8099, past the sequential range.

Types and names

TS8002 UNKNOWN_TYPE Example
A type name that nothing declares, in a parameter, a type argument, an alias, an implements clause or a base class, or a type that this surface does not take where the mapper reads one (Rule 2.1). A base that the file declares and does not collect as a struct is STRUCT_FIELD.
TS8003 TYPE_MISMATCH Example
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.).
TS8005 CONST_ASSIGN Example
An assignment to a name or a place that cannot change: a const number or vector, a component of a const vector or matrix, a readonly field or static, or a storage binding that readonly or "read" promises is never written. A write to a field or an element of a const object is not one of these, because the const holds the object and the object stays writable, as in JavaScript (Rule 6.10).
TS8010 STRUCT_FIELD Example
An invalid struct field or declaration shape. A class with no fields is accepted; this code covers an invalid field declaration, an empty struct that is not a class, an @align on a field, which is not applied, and a user-defined value whose uses give it two locations (Rule 6.6).
TS8016 INDEX_OOB Example
A constant index outside the length of what it indexes.
TS8018 ASSIGN_TARGET Example
An assignment or ++/-- target that is not a writable place, such as a temporary. An unknown name is UNKNOWN_NAME, and a write to a known immutable binding is CONST_ASSIGN.
TS8022 UNKNOWN_NAME Example
A reference to a name that TypeShade cannot resolve and that is not a function call (UNKNOWN_FN) or a type name (UNKNOWN_TYPE). A name that the library declares for TypeScript's own use (Object, Math, Symbol), or that the file declares as an enum, a namespace, a class or a type, and that is read as a value, says what it is.
TS8023 DUPLICATE_SYMBOL Example
The same function, binding, module constant or struct name declared twice in one scope. A struct counts whichever spelling each declaration uses: a class, an interface and a type alias of one name are one struct, so a second declaration is a duplicate.
TS8068 RESERVED_NAME Example
eval or arguments bound by a variable, a parameter or a function, which ECMAScript's strict mode, and TypeScript with it, lets no declaration do (Rule 2.1).
TS8075 UNASSIGNED_READ Example
A read of a local before it is assigned on every path (Rule 7.6), by TypeScript's rule for its TS2454. An argument is a read, and no call assigns the caller's local. The editor shows this code where TypeScript reports TS2454.

Functions and classes

TS8004 UNKNOWN_FN Example
A call to a function the file neither declares nor imports, or to a builtin the language removed because ECMAScript spells it, such as arrayLength(xs), whose message names xs.length (Rule 9.9).
TS8019 ARITY_MISMATCH Example
A wrong number of arguments, elements or fields at a call or a constructor.
TS8020 FUNCTION_SHAPE Example
A function declaration or parameter shape that TypeShade does not support, such as a missing name or body, a rest parameter or a destructured parameter.
TS8021 RETURN_SHAPE Example
A return of the wrong shape: a bare return where a value is required, a function that returns undefined and no value, or a compute entry with no return type annotation that returns a value.
TS8031 RECURSION Example
A call cycle: a function that reaches itself, directly or through other functions. WGSL has no call stack, so the compiler refuses the cycle before a target sees it.
TS8035 CLASS_MEMBER Example
A class member shape that the surface does not take, a use of a member that the class rules refuse, or a new that builds no class (Rule 8.13). Getters and setters, static fields and methods, overload signatures, abstract members, # private names and methods that change their object all compile. The message names the member or the target and the edit.
TS8036 MATH_ARGUMENT Example
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.

Control flow

TS8006 LOOP_BOUND Example
A loop whose condition the compiler refuses: a for with a constant start, bound and step whose counter leaves the range of its type before the condition fails, or a call that writes inside a loop condition. A for...of over an array that is not a name is refused under this code too.
TS8007 LOOP_INFINITE Example
A loop that certainly never ends: a while (true) or a for with no condition, written or folded from constants, with no break or return, or a for with constant bounds whose step does not move the counter toward its bound.
TS8008 LOOP_INDUCTION Example
A for...of loop that does not declare one element, as for (const x of xs) or for (let x of xs) does.
TS8009 BREAK_OUTSIDE Example
A break with no loop or switch around it.
TS8017 SWITCH_CASE Example
An invalid switch case: a label that is not an integer constant, does not fit the selector or repeats another; an empty clause with no body below it to share; a body whose end is reachable above a clause with a body, which TypeScript runs on into and WGSL does not (Rule 7.3); or a continue in a switch that no loop encloses.
TS8034 BARRIER_PLACEMENT Example
workgroupBarrier() or storageBarrier() where a barrier cannot stand: in a vertex or fragment entry, which has no workgroup, or as a value, since a barrier is a statement. A barrier under control flow that the invocations do not share is UNIFORMITY.
TS8052 UNIFORMITY Example
A barrier, a workgroupUniformLoad, or a derivative or implicit-LOD sample that the compiler's rewrite cannot reach, reached under a condition on a non-uniform value, or after a return, break or continue taken under one (Rule 8.5). The message names the value as the author wrote it and the statement.

Entry points and IO

TS8024 BUILTIN_NAME Example
A @builtin("...") with a malformed name argument, or with an id outside WGSL's builtin vocabulary.
TS8025 BUILTIN_STAGE Example
A @builtin(...) id used as the input or output of the wrong stage, for example frag_depth on a vertex return or front_facing on a vertex parameter.
TS8026 WORKGROUP_SHAPE Example
A warning: @compute([x, y, z]) exceeds one of WebGPU's default compute limits (256 for x and y, 64 for z, 256 invocations in all), so a device requested without a raised limit refuses the pipeline.
TS8028 ATTRIBUTE_NAME Example
A decorator or an entry form that this surface does not read: an identifier outside the attribute vocabulary (@vertex, @fragment, @compute, @builtin, @location), such as a misspelled @vertx; a WGSL attribute that the surface writes another way or does not borrow, such as a written @diagnostic(…); a stage written as a call, such as vertex(f); an entry that is written in a form that Rule 8.1 refuses, such as export default; or a decorator on a declaration or in a place that takes none (Rule 6.7). Without this code the decorated function or field would silently stop being an entry point or an I/O field.
TS8029 STRUCT_FIELD_MISSING_ATTR Example
A user-defined input of a compute entry: a parameter, or a field of its struct, that carries no builtin<…>. A compute entry has no user-defined input in WGSL, so the front end refuses it. On a vertex or fragment entry a value with no attribute is user-defined, and the compiler gives it its location (Rule 6.6).
TS8037 WORKGROUP_ARG Example
@compute(...) with an argument that is not an array literal of one to three whole numbers: an object, a bare number, an identifier, or an empty or four-wide array. The check of the default limits is WORKGROUP_SHAPE.

Resources and memory

TS8032 UNSIZED_ARRAY_LENGTH Example
.length on an array<T> with no size that is not in storage: a uniform<array<T>>, a local or a parameter. A runtime-sized storage array reads its length from the buffer. Any other array needs an explicit size.
TS8033 MODULE_VAR Example
A module variable declared or used where its address space forbids it: a const with an address-space wrapper, a workgroup variable with an initializer, a type that the space cannot hold (a texture, a runtime-sized array, an atomic in a per-invocation variable), an initializer that is not a constant, or a workgroup variable reached from a vertex or fragment entry. Also the retired perInvocation<T> wrapper, which a plain top-level let replaced.
TS8041 TEXTURE_ARGUMENT Example
A plain argument of a texture read that the target has no overload for: a coordinate or gradient of the wrong width for the texture's dimension or of an element kind that the read does not take, a layer, mip level or sample index that is not a whole number of 0 or more, or a level, bias or depth_ref that is not an f32. A texture that is wrong for the call, such as a sampled texture handed to textureStore, is TYPE_MISMATCH.
TS8051 LAYOUT Example
A buffer binding's store type that breaks one of WGSL's host-shareable rules: a bool, alone or in a vector, in a uniform or storage binding; a runtime-sized array<T> that is not the last member of its struct; a runtime-sized array in a uniform; or a two-row matrix (mat2x2, mat3x2, mat4x2) in a uniform, which WGSL and std140 lay out at different offsets (Rule 4.8).
TS8079 HOST_RESERVED_FIELD Example
A field of the class of an exported binding that is named like a member of its host accessor (Rule 6.1): set on the class of an exported uniform<T> or of the element of an exported storage array, and needsUpdate or dispose on the class of an exported uniform<T>. The host sets a field through its accessor (camera.pos.set(…)), so a field of the accessor's own name cannot be reached.

Emulated double

TS8027 MAT_UNSUPPORTED Example
A non-square matCxR<f64>: the fp64 pass carries one double-float body for each dimension, so only a square matrix of doubles lowers. Every matCxR<f32> is a type.
TS8038 F64_ENTRY_IO Example
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.

Targets

TS8015 BACKEND Example
A backend that refused to emit a module the front end accepted. The message is the backend's own.

Retired numbers

TS8011
Retired codes.
TS8012
Retired codes.
TS8053
Retired by change 0134 (INT_LITERAL_DEPRECATION): the warning of the window of, an undecided integer-written declaration "types as f32 today; it will type as i32".
TS8078
Retired by change 0131 (numerics): TS8078 was the refused numerical contract of change 0107; change 0131 removed the construct and retired the code.
TS8080
Retired by change 0142 (VALUE_ARRAY_WRITE_LOST): TS8080 was the refused write to an array parameter that no return carries back (change 0138, Amendment A15); change 0142 makes an array parameter the caller's object, so such a write is the program's meaning and no refusal has a true text.

Other codes

TS8069 MISPLACED_DIRECTIVE Example
A "use typeshade" directive after another top-level statement (Rule 3.1). In ECMAScript a directive is only a leading string statement, so TypeScript reads a late one as an ordinary string. The fix is to move the directive, not to add one; a file with no directive at all is MISSING_DIRECTIVE.
TS8070 KERNEL_LOOP_ON_CPU
A warning on a loop of a kernel function (Rule 8.22) that the independence proof refused: the loop runs on the CPU. The message names the line and the names that stop it, and the remedy. The program is correct either way.
TS8071 CONSOLE_NOT_RECORDED Example
A warning under compile(src, { console: 'gpu' }): a console call that the WGSL does not record. The message gives the reason: a vertex entry reaches the call, an argument has no fixed size or is not a value, or the stage has no room for another storage buffer. The call still reaches the sink on the CPU (Rule 11.9).
TS8073 REFERENCE
A reference form that is not supported yet (Rule 8.8, change 0142): @inout or @out, which are removed because an object parameter is the caller's object with no mark, and a call that may give back an object that has a name. The message names the edit.
TS8074 REFERENCE_ALIAS
Two names for one object in one call, where a write reaches one of them: f(a, a) where f writes one of the two, or a module variable passed to a function that also uses its name. The message says that the form is not supported yet (change 0142).
TS8077 KERNEL_WORKGROUP_REDUCES Example
A kernel function with @workgroup_size that has a loop which reduces (Rule 8.22). A reduction always runs in the tree of 256, so an attribute that asks for another size cannot be honored. The message names the function and the remedy.

Core codes

The SDxxxx codes, from the CODES catalogue in typeshade/dev. The core IR layer raises them under the fn() builder and under a "use typeshade" file alike, and the front end refuses many of the same mistakes first under a code of its own.

Types and names

SD0001
matrix × vector size mismatch
SD0002
binary op on mismatched vectors
SD0003
arithmetic op on a bool operand
SD0004
binary op on incompatible types
SD0005
bitwise op requires a u32/i32 left operand
SD0006
component access on a non-vector
SD0007
vector component out of range
SD0008
swizzle on a non-vector
SD0009
.select() on a non-bool condition
SD0010
select branches have differing types
SD0011
matchExpr case type does not match the default
SD0015
array-texture layer must be an integer
SD0116
a scalar cast applied to a non-scalar value
SD0117
a one-argument .at(i) on a node that is not an array

Builder calls

SD0012
statement sink not installed
SD0013
no active builder
SD0113
a fn whose body returns nothing at the TypeScript level returns a value at run time
SD0115
a branch body returned a value, which a branch cannot carry out

Resources and memory

SD0014
override (specialization constant) must be a WGSL scalar type
SD0016
host-owned resource has a shape the target cannot spell
SD0114
a variable a function reads has no declaration in the module

Targets

SD0017
literal cannot be spelled by the target
SD0020
module validation failed
SD0030 Example
unsupported feature for this backend

Emulated double

SD0040
f64 type leaked past fp64Lower into a backend emitter
SD0041
unsupported operation on f64 operands
SD0042
conflicting fp64 guard declaration
SD0043 Example
reserved fp64 name
SD0044
f64 in an interpolated @location IO field

Lint rules

SD0107
assignment to an immutable 'let' binding
SD0108 Example
smoothstep with constant edge0 >= edge1 (undefined in GLSL ES)
SD0109
a fragment-only builtin is reachable from a vertex or compute entry
SD0112
a local name is declared twice in one function

Portable kernels

SD0110
portable declared on a non-compute entry
SD0111
portable kernel outside the gather-only tier

Other codes

SD0118
grad cannot differentiate this function

Numbering

The front end's registry records each gap in its numbering, with the reason:

TS8011 to TS8012: Retired codes. TS8012 was HOST_API, a list of JavaScript globals refused by their spelling; a name nothing declares is UNKNOWN_NAME, UNKNOWN_FN or UNKNOWN_TYPE by its position, and one the file declares is the file's (Rule 2.1). A gap is never reused.

TS8039 to TS8040: Unspent block of #162: while several sessions worked the issue list in parallel, each drew from a block of codes so that two branches in flight could not claim one number twice; F64_ENTRY_IO (TS8038) is the last code of the sequential range, and a block's unused codes (TS8039 to TS8067) stay unspent.

TS8042 to TS8049: Unspent block of #162 (TS8039 to TS8067); TEXTURE_ARGUMENT (TS8041) and RESERVED_NAME (TS8068) were assigned from blocks.

TS8053: Retired by change 0134 (INT_LITERAL_DEPRECATION): the warning of the window of #148, an undecided integer-written declaration "types as f32 today; it will type as i32". Change 0134 infers a number's type from its uses and keeps no default for an author to learn, so the warning has no true text.

TS8054 to TS8067: Unspent block of #162 (TS8039 to TS8067); a block's unused codes stay unspent.

TS8076: Reserved by draft proposal 0052 (not on main), changes/0067-kernel-workgroup-size.md (decision D7) and changes/0107-numerical-contract.md; it stays unused while that draft is open.

TS8078: Retired by change 0131 (numerics): TS8078 was the refused numerical contract of change 0107; change 0131 removed the construct and retired the code.

TS8080: Retired by change 0142 (VALUE_ARRAY_WRITE_LOST): TS8080 was the refused write to an array parameter that no return carries back (change 0138, Amendment A15); change 0142 makes an array parameter the caller's object, so such a write is the program's meaning and no refusal has a true text.

Edit this page Report a problem