Rule 6.5
Chapter 6, Declarations and resources Test
A top-level let is a module variable in the per-invocation (private) address space; workgroup memory must be written let x: workgroup<T>; a module variable must take no declare. A sized array in workgroup memory may use a scalar integer override as its outer element count; its default is the count used by the CPU oracle, and the selected override specializes the WGSL array.
The rule text and the parts under it are the compiler's own English, as the design document writes them.
Rationale
a module-level let already says “a value this invocation owns”, so the address space is read off the syntax and only the space TypeScript cannot express gets a wrapper.
Derives from
Address Spaces; surface §24; the roadmap’s first rule.
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:
TS8033 MODULE_VAR and src/compiler/ts/module-vars.test.ts.
The files that verify it at commit af54ddad5, each at the first line that names the rule:
Explained in
The sections of the surface document that explain this rule, at commit af54ddad5:
Error codes that enforce it
The diagnostic codes the rule names under Enforced by, or whose registry text names the rule:
-
TS8033MODULE_VAR - A module variable declared or used where its address space forbids it: a
constwith an address-space wrapper, aworkgroupvariable 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 aworkgroupvariable reached from a vertex or fragment entry. Also the retiredperInvocation<T>wrapper, which a plain top-levelletreplaced.
See also
- Rule 6.4 Test
- Rule 6.6 Test
- Design rules
- Error codes
Source
The rule at commit af54ddad5:
docs/language-design.md:518(the design document)reqs/rules/RULE-0605.md(its traceability item)