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.
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 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:
-
TS8033MODULE_VAR - A module variable (
let x: workgroup<T>,let y: T = init, §24) declared or used where its address space forbids: aconstwith an address-space wrapper, aworkgroupvariable with an initializer, a type 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 (roadmap 0.2 item 5).
See also
- Rule 6.4 Test
- Rule 6.6 Test
- Design rules
- Error codes
Source
The rule at commit 26de7be8:
docs/language-design.md:427(the design document)reqs/rules/RULE-0605.md(its traceability item)