Rule 8.4
On this page

Rule 8.4

Chapter 8, Functions and entry points Test

A function must not take part in a call cycle, directly or through other functions; the check reads the calls a body writes, and the calls a method call, an accessor and new lower to, before any optimisation, so a call in a branch the optimizer would drop is a cycle too.

The rule text and the parts under it are the compiler's own English, as the design document writes them.

Rationale

WGSL has no call stack, and matching the optimizer would make the answer depend on constant folding an author cannot predict. A call on a value (this.g(n), o.m()), a read or write of an accessor and new name no function in their text, so the check reads them as lowered; before that, a cycle through a method reached Tint.

Derives from

Restrictions on Functions (“recursion is disallowed because cycles are not permitted among any kinds of declarations”); surface §4.

How it is verified

Checked by a test. A test, a gate script or a CI workflow names this rule, and the traceability check fails when a file listed below stops naming it.

Where the rule says the compiler enforces it:

TS8031 RECURSION, on the call that closes the cycle, naming the whole cycle as the author writes its members (Recursive call: "N.f" -> "N.g" -> "N.f". WGSL has no call stack, so a function must not take part in a call cycle.), once for a body a class inherits and once for every instance of a generic function; pinned by src/compiler/ts/namespace.test.ts, src/compiler/ts/default-args.test.ts and src/compiler/ts/class-syntax.test.ts.

The files that verify it at commit 26de7be8, each at the first line that names the rule:

Explained in

The sections of the surface document that explain this rule, at commit 26de7be8:

Error codes that enforce it

The diagnostic codes the rule names under Enforced by, or whose registry text names the rule:

TS8031 RECURSION
A call cycle: a function that reaches itself, directly or through other functions.

See also

Source

The rule at commit 26de7be8:

Edit this page Report a problem