규칙 12.6
12장, 진단 테스트
A requirement the front end can check must be checked at the front end, in the author’s words, and not left to Tint or a driver.
규칙 본문과 그 아래 항목은 설계 문서에 적힌 컴파일러 원문이라 한국어 페이지에서도 영어로 둡니다.
근거
WGSL checks each requirement at the earliest opportunity, and for TypeShade the earliest opportunity is the source line.
출처
Errors (“each requirement will be checked at the earliest opportunity”); surface §3 and §7.
검증 방식
테스트로 확인합니다. 테스트나 게이트 스크립트, CI 워크플로가 이 규칙을 가리키고, 아래 파일 가운데 하나라도 규칙을 더는 가리키지 않으면 추적 검사가 실패합니다.
컴파일러가 이 규칙을 적용하는 곳을 규칙이 직접 적은 내용입니다.
TS8029, TS8031, TS8036, TS8038, TS8068, and the rest of the front-end codes, among them TS8002 for a type the file declares nowhere, which used to be emitted as a struct of that name for Tint to refuse (src/compiler/ts/unknown-names.test.ts); the requirements proposal 0008 moved forward from Tint: a for update the lowering does not count, refused instead of dropped with its loop (Rule 7.5), an operator WGSL has no overload for on its operands’ kind (Rule 7.1), a vector of bools in a uniform or storage binding (Rule 6.8), a decorator nothing reads, @group and @binding on a declaration among them (Rule 6.7), a barrier, a derivative or a workgroupUniformLoad after a non-uniform break or continue (Rule 8.5), and a while condition that is not a bool (Rule 7.5), each pinned where that rule’s Enforced-by names it, and a loop’s hidden counter, which an author’s _w or _i reached (Rule 2.2), pinned by src/compiler/ts/loop-shapes.test.ts; two constant expressions Tint refused, now folded as a divisor is and refused with TS8003: a clamp whose bounds cross (src/compiler/ts/clamp-bounds.test.ts, #373) and an f32 value past the range (src/compiler/ts/f32-const-range.test.ts, #374); the debts of Appendix B are the requirements not yet moved forward.
커밋 af54ddad5에서 이 규칙을 확인하는 파일입니다. 파일마다 규칙을 처음 가리키는 줄로 연결했습니다.
-
src/compiler/ts/array-minmax-types.test.ts:1 -
src/compiler/ts/clamp-bounds.test.ts:1 -
src/compiler/ts/compute-stage-reachability.test.ts:1 -
src/compiler/ts/const-call-domain.test.ts:1 -
src/compiler/ts/f32-const-range.test.ts:1 -
src/compiler/ts/honest-refusals-tuples.test.ts:1 -
src/compiler/ts/honest-refusals.test.ts:1 -
src/compiler/ts/index-bound.test.ts:1 -
src/compiler/ts/io-attribute-arguments.test.ts:1 -
src/compiler/ts/loop-shapes.test.ts:1 -
src/compiler/ts/lower/runtime-array.ts:1 -
src/compiler/ts/module-vars-atomic.test.ts:1 -
src/compiler/ts/runtime-array-values.test.ts:1 -
src/compiler/ts/struct-cycle.test.ts:1 -
src/compiler/ts/switch-validation.test.ts:1 -
src/compiler/ts/unknown-names.test.ts:2
설명하는 절
커밋 af54ddad5의 언어 문서에서 이 규칙을 설명하는 절입니다.
적용하는 오류 코드
규칙이 Enforced by 항목에서 가리키는 진단 코드와, 레지스트리 설명에서 이 규칙을 가리키는 진단 코드입니다.
-
TS8002UNKNOWN_TYPE - 아무것도 선언하지 않은 타입 이름입니다. 매개변수, 타입 인자, 별칭,
implements절, 기반 클래스 어디에 써도 걸리고, 이 표면이 매퍼가 읽는 자리에서 받지 않는 타입도 여기에 속합니다(규칙 2.1). 파일이 선언했지만 구조체로 모으지 않은 기반은STRUCT_FIELD입니다. -
TS8003TYPE_MISMATCH - 연산자나 조건, 선언, 반환, 인자처럼 두 값이 만나는 자리에서 타입이 서로 맞지 않거나, 검사로 좁히지 않은 선택적 값(
T | undefined,T | null,T | null | undefined)을 읽거나(규칙 7.10), 컴파일러가 접는 상수를 WGSL이 거부합니다. 31을 넘는 시프트 양, 0인 제수, 서로 엇갈린 clamp 경계, 범위를 넘는f32값,Math.pow(-2., 2.)처럼 정의역 밖에서 부르는 내장 함수가 그렇습니다. -
TS8029STRUCT_FIELD_MISSING_ATTR - compute 진입점의 사용자 정의 입력입니다.
builtin<…>가 없는 매개변수나 그 구조체의 필드가 그렇습니다. WGSL의 compute 진입점에는 사용자 정의 입력이 없으므로 프런트엔드가 거부합니다. 정점이나 프래그먼트 진입점에서는 속성이 없는 값이 사용자 정의 값이고, 컴파일러가 location을 줍니다(규칙 6.6). -
TS8031RECURSION - 호출 순환입니다. 함수가 직접, 또는 다른 함수를 거쳐 자기 자신에 닿습니다. WGSL에는 호출 스택이 없으므로 컴파일러가 타깃이 보기 전에 순환을 거부합니다.
-
TS8036MATH_ARGUMENT - 시그니처가 받지 않는 인자로 수학 내장 함수를 부릅니다. 모양이 맞아야 하는 두 값(
dot(vec3, vec2)), 내장 함수에 해당 형태가 없는 요소 종류(정수 벡터의sin), 벡터가 와야 할 곳의 스칼라(normalize(s)), 타입이 잘못된 계수, 지수, 오프셋, 개수가 그렇습니다. 메시지는 문제의 인자와, 짧게 고칠 수 있으면 방법을 알려 줍니다. 스칼라를 펼치거나, 한쪽을 변환하거나, 벡터 크기를 맞춥니다. -
TS8038F64_ENTRY_IO - 에뮬레이트한 double(
f64나vec64)이 진입점의 IO 경계에 있습니다.@location매개변수, IO 구조체의@location필드, 진입점의 반환값이 그렇습니다. double은 낮춘 뒤f32워드 두 개이고, varying은 워드를 따로 보간합니다.f32(x)로 좁히거나, 필요한 스테이지에서 double을 읽으세요. uniform과 스토리지 바인딩은f64를 담을 수 있습니다. -
TS8068RESERVED_NAME - 변수, 매개변수, 함수가
eval이나arguments를 이름으로 씁니다. ECMAScript의 엄격 모드와 그에 따르는 TypeScript가 어떤 선언도 허용하지 않는 이름입니다(규칙 2.1).
함께 보기
소스
커밋 af54ddad5의 규칙 원문:
docs/language-design.md:1758(설계 문서)reqs/rules/RULE-1206.md(추적 항목)