TS8010
Front-end code STRUCT_FIELD
An invalid struct field or declaration shape.
The registry text and every compiler message on these pages are the compiler's own English.
When it fires
An invalid struct field or declaration shape. Fieldless classes are accepted; this code still covers invalid field declarations and unsupported empty non-class structs.
Example
"use typeshade"
class Tint { rgb: vec3 alpha: f32}
function tint(uv: vec2): Tint { return { rgb: vec3(uv, 0.) }}
@fragmentexport function main(@location(0) uv: vec2): vec4 { return vec4(tint(uv).rgb, 1.)}Compiled at build time against the pinned compiler, this program gets:
TS8010 error, line 9: Missing field "alpha" for struct Tint.
How to fix it
The same program, corrected. It compiles with no diagnostic.
"use typeshade"
class Tint { rgb: vec3 alpha: f32}
function tint(uv: vec2): Tint { return { rgb: vec3(uv, 0.), alpha: 1. }}
@fragmentexport function main(@location(0) uv: vec2): vec4 { return vec4(tint(uv).rgb, 1.)}The rules this enforces
- Rule 6.8 Test
- The byte layout the emitted module assumes for a resource and the layout
reflect()reports must agree byte for byte, under WGSL’s uniform and storage layout rules, and so must the layout the manifest carries (Rule 11.10); a vertex entry’s vertex buffer is one layout, its@locationinputs tightly packed in the order written, whichreflect().vertexand the manifest both report. - Rule 6.9 Test
- A struct must be the members written in it, in one of three spellings (
class,interface, atypeover an object literal). - Rule 8.12 Test
- A private name
#xmust be emitted without its#: a field as the struct memberx, a method asOwner_x, an accessor asOwner_get_xandOwner_set_x, a static field asOwner_x. - Rule 8.14 Test
- A constructor’s parameter property (
constructor(public x: f32), orprivate,protectedorreadonlyin place ofpublic) is a field of its class, at the constructor’s place among the members, which the constructor assigns from the parameter before the field initializers run. - Rule 8.15 Test
- A member declared
privatemay be named only inside the body of the class that declares it, and one declaredprotectedonly inside the bodies of that class and of the classes that extend it, on an object of the naming body’s own class or of one that extends it; a name either rule does not allow must be refused with the remedy.
See also
-
SD0020 - module validation failed
Source
Where the compiler raises this code at commit 26de7be8, one line per file: