TS8010
프런트엔드 코드 STRUCT_FIELD
An invalid struct field or declaration shape.
레지스트리 설명과 컴파일러 메시지는 컴파일러 원문이라 한국어 페이지에서도 영어로 둡니다.
발생 조건
An invalid struct field or declaration shape. Fieldless classes are accepted; this code still covers invalid field declarations and unsupported empty non-class structs.
예제
"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.)}빌드할 때 고정된 컴파일러로 이 프로그램을 컴파일하면 다음 진단이 나옵니다.
TS8010 error, 9행: Missing field "alpha" for struct Tint.
고치는 법
같은 프로그램을 고친 모습입니다. 진단 없이 컴파일됩니다.
"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.)}이 코드가 적용하는 규칙
- 규칙 6.8 테스트
- 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. - 규칙 6.9 테스트
- A struct must be the members written in it, in one of three spellings (
class,interface, atypeover an object literal). - 규칙 8.12 테스트
- 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. - 규칙 8.14 테스트
- 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. - 규칙 8.15 테스트
- 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.
함께 보기
-
SD0020 - module validation failed
소스
커밋 c66579bf에서 컴파일러가 이 코드를 내는 곳입니다. 파일마다 한 줄씩 적었습니다.