Rule 8.1
Chapter 8, Functions and entry points Test
An entry point is a function declaration at the top of the file or of a namespace, exported or not, with exactly one stage attribute written before the declaration: @vertex export function vs(…), @fragment …, or @compute([x, y?, z?]) …. The order export @vertex function is accepted and means the same. An entry takes its declaration’s name, so export default on an entry must be refused with TS8028 (“an entry takes its declaration’s name; write export function k”) (change 0130, D4, as amended by change 0140). A bare @compute and @compute() take the default size (Rule 8.7). @vertex and @fragment take no argument list: @vertex() and an argument on either must be refused with TS8028. An entry written as a const, an arrow function or a function expression, and an entry method on a class, must be refused; the stage calls of change 0111 are refused (Rule 6.7).
The rule text and the parts under it are the compiler's own English, as the design document writes them.
Rationale
this is not a GPU instance, and an entry has no receiver. The stage marks the function, so it is the language’s attribute on the declaration (Rule 1.8).
Derives from
Entry Points; change 0111 (D1, replaced by change 0130); change 0130; change 0140; surface §3 and §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:
the front end’s entry reading in src/compiler/ts/source-file.ts and decorated-form.ts, pinned by src/compiler/ts/stage3.test.ts (both orders, a namespace entry, two stage attributes refused, an argument on @vertex or @fragment refused in both halves with TS8028, "@vertex" takes no argument: write "@vertex" and delete "(1)" (Rule 8.1)., the empty argument list, @vertex() or @fragment(), refused with the same sentence and delete "()" while @compute() stays accepted (change 0130, amendment A1), a type argument on a stage attribute or on @workgroup_size refused as a decorator that is not a name is (Rule 6.7), export default refused on default in both halves), src/compiler/ts/stage-call.test.ts (an entry written as a const, an arrow function or a function expression through a stage call, refused in both halves) and src/language-service/new-entry-forms.test.ts; TS8035 (A decorator has no place on "C.k"; an entry is a function declaration with a stage attribute, "@vertex export function vs(…) { … }".), beside surface §7’s row “@compute method on a class”.
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:
-
TS8028ATTRIBUTE_NAME - A decorator or an entry form that this surface does not read: an identifier outside the attribute vocabulary (
@vertex,@fragment,@compute,@builtin,@location), such as a misspelled@vertx; a WGSL attribute that the surface writes another way or does not borrow, such as a written@diagnostic(…); a stage written as a call, such asvertex(f); an entry that is written in a form that Rule 8.1 refuses, such asexport default; or a decorator on a declaration or in a place that takes none (Rule 6.7). Without this code the decorated function or field would silently stop being an entry point or an I/O field. -
TS8035CLASS_MEMBER - A class member shape that the surface does not take, a use of a member that the class rules refuse, or a
newthat builds no class (Rule 8.13). Getters and setters, static fields and methods, overload signatures, abstract members,#private names and methods that change their object all compile. The message names the member or the target and the edit.
See also
Source
The rule at commit af54ddad5:
docs/language-design.md:780(the design document)reqs/rules/RULE-0801.md(its traceability item)