TS8007
On this page

TS8007

Front-end code LOOP_INFINITE

A loop that certainly never ends: a while whose condition is true, written or folded from constants, with no break or return, or a step that moves the counter away from its bound.

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(@location(0) uv: vec2): vec4 {
let g = uv.x
while (true) {
g = g * 0.5
}
return vec4(g, g, g, 1.)
}

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

TS8007 error, line 6: while (true) has no break or return in its body, so it never ends. Leave it with a break, or write the exit into the condition.

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 {
let g = uv.x
for (let i = 0; i < 4; i++) {
g = g * 0.5
}
return vec4(g, g, g, 1.)
}

The rule this enforces

Rule 7.5 Test
A for loop must be counted: an i32 or u32 induction variable, a constant step, and an exit that compares the induction variable to a bound; the start and the bound may be runtime values, the loop body must not write the bound, and the step must move the variable toward the bound.

See also

Source

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

Edit this page Report a problem