규칙 8.1
이 페이지에서

규칙 8.1

8장, 함수와 진입점 테스트

An entry point is a function declaration at the top of the file or of a namespace, exported or not, with exactly one stage attribute written before the declaration: @vertex export function vs(…), @fragment …, or @compute([x, y?, z?]) …. The order export @vertex function is accepted and means the same. An entry takes its declaration’s name, so export default on an entry must be refused with TS8028 (“an entry takes its declaration’s name; write export function k”) (change 0130, D4, as amended by change 0140). A bare @compute and @compute() take the default size (Rule 8.7). @vertex and @fragment take no argument list: @vertex() and an argument on either must be refused with TS8028. An entry written as a const, an arrow function or a function expression, and an entry method on a class, must be refused; the stage calls of change 0111 are refused (Rule 6.7).

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

근거

this is not a GPU instance, and an entry has no receiver. The stage marks the function, so it is the language’s attribute on the declaration (Rule 1.8).

출처

Entry Points; change 0111 (D1, replaced by change 0130); change 0130; change 0140; surface §3 and §4.

검증 방식

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

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

the front end’s entry reading in src/compiler/ts/source-file.ts and decorated-form.ts, pinned by src/compiler/ts/stage3.test.ts (both orders, a namespace entry, two stage attributes refused, an argument on @vertex or @fragment refused in both halves with TS8028, "@vertex" takes no argument: write "@vertex" and delete "(1)" (Rule 8.1)., the empty argument list, @vertex() or @fragment(), refused with the same sentence and delete "()" while @compute() stays accepted (change 0130, amendment A1), a type argument on a stage attribute or on @workgroup_size refused as a decorator that is not a name is (Rule 6.7), export default refused on default in both halves), src/compiler/ts/stage-call.test.ts (an entry written as a const, an arrow function or a function expression through a stage call, refused in both halves) and src/language-service/new-entry-forms.test.ts; TS8035 (A decorator has no place on "C.k"; an entry is a function declaration with a stage attribute, "@vertex export function vs(…) { … }".), beside surface §7’s row “@compute method on a class”.

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

설명하는 절

커밋 af54ddad5의 언어 문서에서 이 규칙을 설명하는 절입니다.

적용하는 오류 코드

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

TS8028 ATTRIBUTE_NAME
이 표면이 읽지 않는 데코레이터나 진입점 형태입니다. 속성 어휘(@vertex, @fragment, @compute, @builtin, @location) 밖의 식별자(@vertx 같은 오타), 표면이 다른 방식으로 쓰거나 빌려 오지 않는 WGSL 속성(직접 쓴 @diagnostic(…) 같은 것), vertex(f)처럼 호출로 쓴 스테이지, export default처럼 규칙 8.1이 거부하는 형태로 쓴 진입점, 데코레이터를 받지 않는 선언이나 자리에 붙은 데코레이터가 그렇습니다(규칙 6.7). 이 코드가 없으면 데코레이터를 붙인 함수나 필드가 아무 말 없이 진입점이나 IO 필드가 아니게 됩니다.
TS8035 CLASS_MEMBER
표면이 받지 않는 클래스 멤버 모양, 클래스 규칙이 거부하는 멤버 사용, 클래스를 만들지 않는 new입니다(규칙 8.13). getter와 setter, static 필드와 메서드, 오버로드 시그니처, abstract 멤버, # 비공개 이름, 객체를 바꾸는 메서드는 모두 컴파일됩니다. 메시지가 멤버나 대상과 고칠 방법을 알려 줍니다.

함께 보기

소스

커밋 af54ddad5의 규칙 원문:

이 페이지 편집 문제 보고