TS8010
프런트엔드 코드 STRUCT_FIELD
구조체 필드나 선언의 모양이 잘못되었습니다. 필드가 없는 클래스는 받아들입니다. 이 코드는 잘못된 필드 선언, 클래스가 아닌 빈 구조체, 적용되지 않는 필드의 @align, 사용처마다 location이 둘로 갈리는 사용자 정의 값을 다룹니다(규칙 6.6).
레지스트리에는 이 상수에 대한 문서 주석이 없습니다. 그래서 위 설명은 컴파일러가 이 코드와 함께 내는 메시지를 보고 이 사이트가 쓴 것입니다.
레지스트리 설명과 컴파일러 메시지는 컴파일러 원문이라 한국어 페이지에서도 영어로 둡니다.
예제
"use typeshade"
class Tint { rgb: vec3 alpha: f32}
function tint(uv: vec2): Tint { return { rgb: vec3(uv, 0.) }}
@fragmentexport function main(uv: location<0, 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(uv: location<0, vec2>): vec4 { return vec4(tint(uv).rgb, 1.)}이 코드가 적용하는 규칙
- 규칙 6.6 테스트
- An entry point’s inputs and outputs are explicit parameters and return values.
- 규칙 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 and numbered in that order where nolocation<n, T>states the number (Rule 6.6), whichreflect().vertexand the manifest both report. - 규칙 6.9 테스트
- A struct must be the members written in it, in one of four spellings (
class,interface, atypeover an object literal, an object type literal written where a type stands). - 규칙 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
소스
커밋 af54ddad5에서 컴파일러가 이 코드를 내는 곳입니다. 파일마다 한 줄씩 적었습니다.
-
src/compiler/ts/entry-locations.ts:69 -
src/compiler/ts/lower/expression-prop/object-literal.ts:74(5곳) -
src/compiler/ts/lower/function-signature/parameters.ts:316 -
src/compiler/ts/source-file.ts:383 -
src/compiler/ts/structs/diagnostics.ts:11 -
src/compiler/ts/structs/entry-io.ts:186(2곳) -
src/language-service/diagnostics/refusal-tables.ts:10