Rule 8.8
Chapter 8, Functions and entry points Test
A parameter an author writes must be passed by value; there must be no pointers and no reference parameters. Whole-value assignment, compound assignment and integer updates of a value parameter must rebind a mutable local initialized from the input, leaving the caller’s value unchanged. Only a parameter whose declaration a whole write resolves to gets this local; a shadowing declaration does not count. Within that body’s scope the local may be written through its fields or elements. A parameter with no whole write retains its existing read-only place semantics. Resource handles and the reference-backed arrays of Rule 8.23 are not local-copy values. The object of a method that changes its object, and a variable of the function around it that a local function writes, are not parameters an author writes: Rules 8.10 and 8.17 govern them, and each is passed by reference. The one exception an author writes is a kernel function’s parameter of an array with no size, which is the caller’s storage and passed by reference (Rule 8.23).
The rule text and the parts under it are the compiler's own English, as the design document writes them.
Rationale
whether a parameter is a reference is a language decision the roadmap places after 1.0. The two references are how the emitted function keeps TypeScript’s own meaning (a method writes the object it was called on, a closure writes the variable it closes over), and no author writes either one.
Derives from
docs/roadmap.md After 1.0 (“pointers and reference parameters”); Function Calls.
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:
TS8020 FUNCTION_SHAPE for a parameter shape the surface does not take.
Value rebinding, caller isolation, captures, class bodies, generic/higher-order copies and
entry inputs are pinned by src/compiler/ts/mutable-parameters.test.ts; the immutable GPU
input and distinct local by src/compiler/ts/tint-invalid.test.ts; the packed-package
path by journeys/mutable-parameters/.
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:
-
TS8020FUNCTION_SHAPE - A function declaration or parameter shape TypeShade does not support (missing name or body, optional/rest/destructured parameter).
See also
Source
The rule at commit 26de7be8:
docs/language-design.md:674(the design document)reqs/rules/RULE-0808.md(its traceability item)