규칙 6.9
이 페이지에서

규칙 6.9

6장, 선언과 리소스 테스트

A struct must be the members written in it, in one of three spellings (class, interface, a type over an object literal). On a class or an interface with an extends clause it must be the base’s members first and its own after, through a chain of any depth. A class’s members include the fields its constructor’s parameter properties declare, and a field written without a type takes the one its initializer names (Rule 8.14). An interface that declares a method is a contract and not a struct: a class may name it in implements and a type parameter in its constraint (<T extends Shape>), and a value typed by it must be refused with the remedy, once, where the interface declares the method. A call signature, an index signature, and an optional member must be refused.

규칙 본문과 그 아래 항목은 설계 문서에 적힌 컴파일러 원문이라 한국어 페이지에서도 영어로 둡니다.

근거

a WGSL structure has no form for any of the three, and dropping one silently would change the buffer layout the host fills; a base’s members are laid out where TypeScript’s structural typing says they are, so an extends drops nothing. An interface with a method says what a class supplies, and a call through it runs the body of the class the value is, which static dispatch finds through that class or through the type parameter a call binds (Rule 8.9); a value of the interface’s own type would have to pick the body at run time, which a WGSL function cannot.

출처

Structure Types; TypeScript’s implements clauses and generic constraints; surface §2; surface §26 (“extends, abstract and implements”, roadmap 0.3 item T5, #92; “An interface with methods is a contract”).

검증 방식

테스트로 확인합니다. 테스트나 게이트 스크립트, CI 워크플로가 이 규칙을 가리키고, 아래 파일 가운데 하나라도 규칙을 더는 가리키지 않으면 추적 검사가 실패합니다.

컴파일러가 이 규칙을 적용하는 곳을 규칙이 직접 적은 내용입니다.

TS8010 STRUCT_FIELD, pinned by src/compiler/ts/type-structs.test.ts (a method signature on an interface a value is typed by, "Bad" declares a method, so it is a contract a class implements and not a value a shader holds: take the class that implements it, or a type parameter it constrains, "<T extends Bad>(v: T)".; a call signature, an index signature, an optional field); src/compiler/ts/class-syntax.test.ts for a contract in implements and in a constraint, held to one value on every CPU path, and examples/class-parts.shade.ts in the compile gate; src/compiler/ts/inheritance.test.ts (a derived struct is its base plus its own) for the layout.

커밋 c66579bf에서 이 규칙을 확인하는 파일입니다. 파일마다 규칙을 처음 가리키는 줄로 연결했습니다.

설명하는 절

커밋 c66579bf의 표면 문서에서 이 규칙을 설명하는 절입니다.

적용하는 오류 코드

규칙이 Enforced by 항목에서 가리키는 진단 코드와, 레지스트리 설명에서 이 규칙을 가리키는 진단 코드입니다.

TS8010 STRUCT_FIELD
An invalid struct field or declaration shape.

함께 보기

소스

커밋 c66579bf의 규칙 원문:

이 페이지 편집 문제 보고