TS8006
Front-end code LOOP_BOUND
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.
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
"use typeshade"
@fragmentexport function main(uv: location<0, vec2>): vec4 { let g = 0. for (let i: u32 = 0; i <= 4294967295; i++) { g += 0.1 } return vec4(g, g, g, 1.)}Compiled at build time against the pinned compiler, this program gets:
TS8006 error, line 6: for (i = 0; i <= 4294967295; i += 1) walks "i" outside the range of u32 before the condition fails.
How to fix it
The same program, corrected. It compiles with no diagnostic.
"use typeshade"
@fragmentexport function main(uv: location<0, vec2>): vec4 { let g = 0. for (let i: u32 = 0; i < 4294967295; i++) { g += 0.1 } return vec4(g, g, g, 1.)}The rules this enforces
- Rule 7.5 Test
- A
forloop means what it means in TypeScript: its initializer runs once, its condition (truewhen it has none) is tested before each trip, and its update runs after each trip and at eachcontinue(change 0136). - Rule 7.9 Test
- An expression must be evaluated left to right, as TypeScript and WGSL both evaluate it, and a call that writes (its object, a module variable, a storage binding, an atomic location) inside a larger expression must take effect in that order on every target.
See also
Source
Where the compiler raises this code at commit af54ddad5, one line per file: