Rule 6.7
On this page

Rule 6.7

Chapter 6, Declarations and resources Test

The attribute names the compiler reads are @vertex, @fragment, @compute, @builtin, @location, @interpolate, @invariant, @blend_src, and @diagnostic (the last four since #168, surface §53 and §54); every other WGSL attribute is either inferred by the compiler or carried as an argument (@compute([64, 1, 1]) carries @workgroup_size), and a decorator outside that list must be refused.

The rule text and the parts under it are the compiler's own English, as the design document writes them.

Rationale

a misspelled decorator would otherwise silently stop a function being an entry point.

Derives from

Attributes; the fixture’s attributes list against the ambient library.

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:

TS8028 ATTRIBUTE_NAME and surface-names.test.ts; a WGSL attribute the surface writes another way is named as WGSL’s, with where its intent goes ("@workgroup_size" is WGSL's attribute, written here as @compute's argument: @compute([64]) or @compute([8, 8]).), and not as an unknown one, @size anywhere but a field and @align anywhere but a field or a class as a struct field’s ("@align" is WGSL's attribute for a struct field, not a function. Remove it.), and @std140 anywhere but a class as not applied; every decorator nothing reads is TS8028: on a declaration that takes none (a binding of any kind, an override, a const or let at any depth, an enum, an interface, a type alias, a namespace, a local function, a local class, a class expression, a static field), on a constructor, an overload signature, an abstract member, a mixin or an index signature, on a parameter of one of those, and one that is not a name, anywhere ("@N.k" is not applied: an attribute is written "@name" or "@name(...)". Remove it.); @group and @binding are named as not applied since reflect() reports the group and slot each binding gets, @id as not applied since the host sets an override by its name, and an attribute of the list written where the place does not apply it by what it marks ("@location" does not apply to a parameter of a function that is not an entry: it marks an entry's input or output. Remove it., which Tint refuses too, Rule 12.6; on an overload signature, Write it on the implementation.); a method’s decorator, a function-valued field’s included (Rule 8.16), is TS8035 once, and the method is lowered, so a call of it says nothing more; the editor’s merge drops whatever TypeScript says inside a decorator the compiler refuses whole, its TS1206, TS1239, TS1249 and its TS2304 on a name the ambient library does not declare, and on a method its TS2318 for TypedPropertyDescriptor (Rule 12.4), and its TS1206 filter takes a namespace’s function and its parameters as it takes a top-level one’s, since the compiler reads both (Rule 12.7); a static block, refused whole, keeps TypeScript’s TS1206 on its decorator; pinned by src/compiler/ts/stage3.test.ts, which also holds the attributes it answers for to the fixture’s WGSL list and reads the editor’s diagnostics on each case, and src/language-service/service.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:

TS8028 ATTRIBUTE_NAME
A decorator identifier outside the attribute vocabulary "use typeshade" defines (@vertex, @fragment, @compute, @builtin, @location), e.g. a misspelled @vertx: without this, the decorated function or field just silently stops being an entry point or an I/O field.
TS8035 CLASS_MEMBER
A class member shape the surface does not take, or a use of a member the class rules refuse, and a new that builds no class (Rule 8.13).

See also

Source

The rule at commit 26de7be8:

Edit this page Report a problem