Rule 8.23
Chapter 8, Functions and entry points Test
A kernel function’s parameter of an array with no size is the caller’s storage, passed by reference: the body reads and writes its elements in place, reads its .length, and cannot assign it whole; whether the body writes it decides its access.
A kernel function is emitted by no target, since it runs on the host’s side of the call; an array<T, N> parameter stays by value.
The rule text and the parts under it are the compiler's own English, as the design document writes them.
Rationale
render(k, 512, img) fills img, which is TypeScript’s own meaning of a typed-array argument, and a runtime-sized array exists only in storage (Rule 12.6), so a copy has no meaning.
Derives from
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:
parseParams and fillFunctionBody in src/compiler/ts/lower/function.ts, which take the parameter as an inout storage array for a kernel function and refuse it on any other (TS8020); withoutKernels in src/core/ir/kernels.ts, which every backend and reflect() read through; pinned by src/compiler/ts/kernel-loops.test.ts, which runs a kernel function on the CPU oracle and holds the caller’s array written in place.
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:879(the design document)reqs/rules/RULE-0823.md(its traceability item)