규칙 8.20
8장, 함수와 진입점 테스트
A function a host file can call through an import of its module is an exported function that is not an entry point, is not generic, takes no function, has a host value (Rule 8.21) for each parameter and for its result, and reaches, through the calls of its body, no binding, no workgroup variable and no builtin only a GPU computes (a derivative, a barrier, an atomic, an implicit-LOD texture sample).
An exported @compute entry is callable too, and a full-screen @fragment entry draws into a canvas, as Rule 8.24 says; a kernel function (Rule 8.22) is callable, asynchronously, as this rule’s last paragraph says; a vertex entry is not callable yet.
An exported constant and an enum are values of the host face, and an exported struct is a type of it, as is a struct another file declares where an export’s signature names it; what a module re-exports from a shader file it imports (Rule 3.9) is one of its exports; every other export is declared never in the host view, with the reason and the work that adds it, so a call of one is a type error at the host’s own line.
규칙 본문과 그 아래 항목은 설계 문서에 적힌 컴파일러 원문이라 한국어 페이지에서도 영어로 둡니다.
근거
a host call runs on the CPU tier (Rule 11.7), which has no device, so what it reaches must be computable there with nothing a host call does not pass; a generic function and a function that takes a function exist only as the copies the module’s own calls make (Rules 8.9 and 8.18), and a host call names no such copy.
The IR does not keep the source’s export list (a generic function is its instances, a method is P_len, an enum is its member constants), so the host face is read off the source’s exports and the lowering’s symbol table.
An export the host cannot use is still declared, as never, because an import of a name the view leaves out would be any in a host program that does not check it, and a crash at run time.
출처
검증 방식
테스트로 확인합니다. 테스트나 게이트 스크립트, CI 워크플로가 이 규칙을 가리키고, 아래 파일 가운데 하나라도 규칙을 더는 가리키지 않으면 추적 검사가 실패합니다.
컴파일러가 이 규칙을 적용하는 곳을 규칙이 직접 적은 내용입니다.
hostFace in src/compiler/ts/host-face.ts, which computes the callable set and the reason for each other export; pinned by src/compiler/ts/host-face.test.ts, one case per exclusion, and by its host programs type-checked against the view, in which a call of an export declared never is TS2349.
커밋 c66579bf에서 이 규칙을 확인하는 파일입니다. 파일마다 규칙을 처음 가리키는 줄로 연결했습니다.
설명하는 절
커밋 c66579bf의 표면 문서에서 이 규칙을 설명하는 절입니다.
함께 보기
소스
커밋 c66579bf의 규칙 원문:
docs/language-design.md:838(설계 문서)reqs/rules/RULE-0820.md(추적 항목)