---
title: "규칙 12.6: 진단, TypeShade 셰이더 언어 설계 규칙과 그 근거, 출처, 검증 방식"
description: "TypeShade 언어 설계 규칙 12.6(진단)입니다. A requirement the front end can check must be checked at the front end, in the author's words…"
url: https://typeshade.dev/ko/reference/rules/12-6/
language: ko
---

# 규칙 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](https://gpuweb.github.io/gpuweb/wgsl/#errors) (“each requirement will be checked at the earliest opportunity”); surface §3 and §7.

## 검증 방식

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

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

[`TS8029`](https://typeshade.dev/ko/reference/errors/ts8029/), [`TS8031`](https://typeshade.dev/ko/reference/errors/ts8031/), [`TS8036`](https://typeshade.dev/ko/reference/errors/ts8036/), [`TS8038`](https://typeshade.dev/ko/reference/errors/ts8038/), [`TS8068`](https://typeshade.dev/ko/reference/errors/ts8068/), and the rest of the front-end codes, among them [`TS8002`](https://typeshade.dev/ko/reference/errors/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](https://typeshade.dev/ko/reference/rules/7-5/)), an operator WGSL has no overload for on its operands’ kind ([Rule 7.1](https://typeshade.dev/ko/reference/rules/7-1/)), a vector of bools in a uniform or storage binding ([Rule 6.8](https://typeshade.dev/ko/reference/rules/6-8/)), a decorator nothing reads, `@group` and `@binding` on a declaration among them ([Rule 6.7](https://typeshade.dev/ko/reference/rules/6-7/)), a barrier, a derivative or a `workgroupUniformLoad` after a non-uniform `break` or `continue` ([Rule 8.5](https://typeshade.dev/ko/reference/rules/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](https://typeshade.dev/ko/reference/rules/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`](https://typeshade.dev/ko/reference/errors/ts8003/): a `clamp` whose bounds cross (`src/compiler/ts/clamp-bounds.test.ts`, [#373](https://github.com/typeshade/typeshade/issues/373)) and an `f32` value past the range (`src/compiler/ts/f32-const-range.test.ts`, [#374](https://github.com/typeshade/typeshade/issues/374)); the debts of Appendix B are the requirements not yet moved forward.

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

- [`src/compiler/ts/array-minmax-types.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/array-minmax-types.test.ts#L1)
- [`src/compiler/ts/clamp-bounds.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/clamp-bounds.test.ts#L1)
- [`src/compiler/ts/compute-stage-reachability.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/compute-stage-reachability.test.ts#L1)
- [`src/compiler/ts/const-call-domain.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/const-call-domain.test.ts#L1)
- [`src/compiler/ts/f32-const-range.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/f32-const-range.test.ts#L1)
- [`src/compiler/ts/honest-refusals-tuples.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/honest-refusals-tuples.test.ts#L1)
- [`src/compiler/ts/honest-refusals.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/honest-refusals.test.ts#L1)
- [`src/compiler/ts/index-bound.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/index-bound.test.ts#L1)
- [`src/compiler/ts/io-attribute-arguments.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/io-attribute-arguments.test.ts#L1)
- [`src/compiler/ts/loop-shapes.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/loop-shapes.test.ts#L1)
- [`src/compiler/ts/lower/runtime-array.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/lower/runtime-array.ts#L1)
- [`src/compiler/ts/module-vars-atomic.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/module-vars-atomic.test.ts#L1)
- [`src/compiler/ts/runtime-array-values.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/runtime-array-values.test.ts#L1)
- [`src/compiler/ts/struct-cycle.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/struct-cycle.test.ts#L1)
- [`src/compiler/ts/switch-validation.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/switch-validation.test.ts#L1)
- [`src/compiler/ts/unknown-names.test.ts:2`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/unknown-names.test.ts#L2)

## 설명하는 절

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

- [§3 Entries — stage attributes and explicit builtins](https://github.com/typeshade/typeshade/blob/af54ddad5/docs/use-typeshade-surface.md#3-entries--stage-attributes-and-explicit-builtins)

## 적용하는 오류 코드

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

**[`TS8002`](https://typeshade.dev/ko/reference/errors/ts8002/) `UNKNOWN_TYPE`**

아무것도 선언하지 않은 타입 이름입니다. 매개변수, 타입 인자, 별칭, `implements` 절, 기반 클래스 어디에 써도 걸리고, 이 표면이 매퍼가 읽는 자리에서 받지 않는 타입도 여기에 속합니다([규칙 2.1](https://typeshade.dev/ko/reference/rules/2-1/)). 파일이 선언했지만 구조체로 모으지 않은 기반은 `STRUCT_FIELD`입니다.

**[`TS8003`](https://typeshade.dev/ko/reference/errors/ts8003/) `TYPE_MISMATCH`**

연산자나 조건, 선언, 반환, 인자처럼 두 값이 만나는 자리에서 타입이 서로 맞지 않거나, 검사로 좁히지 않은 선택적 값(`T | undefined`, `T | null`, `T | null | undefined`)을 읽거나([규칙 7.10](https://typeshade.dev/ko/reference/rules/7-10/)), 컴파일러가 접는 상수를 WGSL이 거부합니다. 31을 넘는 시프트 양, 0인 제수, 서로 엇갈린 clamp 경계, 범위를 넘는 `f32` 값, `Math.pow(-2., 2.)`처럼 정의역 밖에서 부르는 내장 함수가 그렇습니다.

**[`TS8029`](https://typeshade.dev/ko/reference/errors/ts8029/) `STRUCT_FIELD_MISSING_ATTR`**

compute 진입점의 사용자 정의 입력입니다. `builtin<…>`가 없는 매개변수나 그 구조체의 필드가 그렇습니다. WGSL의 compute 진입점에는 사용자 정의 입력이 없으므로 프런트엔드가 거부합니다. 정점이나 프래그먼트 진입점에서는 속성이 없는 값이 사용자 정의 값이고, 컴파일러가 location을 줍니다([규칙 6.6](https://typeshade.dev/ko/reference/rules/6-6/)).

**[`TS8031`](https://typeshade.dev/ko/reference/errors/ts8031/) `RECURSION`**

호출 순환입니다. 함수가 직접, 또는 다른 함수를 거쳐 자기 자신에 닿습니다. WGSL에는 호출 스택이 없으므로 컴파일러가 타깃이 보기 전에 순환을 거부합니다.

**[`TS8036`](https://typeshade.dev/ko/reference/errors/ts8036/) `MATH_ARGUMENT`**

시그니처가 받지 않는 인자로 수학 내장 함수를 부릅니다. 모양이 맞아야 하는 두 값(`dot(vec3, vec2)`), 내장 함수에 해당 형태가 없는 요소 종류(정수 벡터의 `sin`), 벡터가 와야 할 곳의 스칼라(`normalize(s)`), 타입이 잘못된 계수, 지수, 오프셋, 개수가 그렇습니다. 메시지는 문제의 인자와, 짧게 고칠 수 있으면 방법을 알려 줍니다. 스칼라를 펼치거나, 한쪽을 변환하거나, 벡터 크기를 맞춥니다.

**[`TS8038`](https://typeshade.dev/ko/reference/errors/ts8038/) `F64_ENTRY_IO`**

에뮬레이트한 double(`f64`나 `vec64`)이 진입점의 IO 경계에 있습니다. `@location` 매개변수, IO 구조체의 `@location` 필드, 진입점의 반환값이 그렇습니다. double은 낮춘 뒤 `f32` 워드 두 개이고, varying은 워드를 따로 보간합니다. `f32(x)`로 좁히거나, 필요한 스테이지에서 double을 읽으세요. uniform과 스토리지 바인딩은 `f64`를 담을 수 있습니다.

**[`TS8068`](https://typeshade.dev/ko/reference/errors/ts8068/) `RESERVED_NAME`**

변수, 매개변수, 함수가 `eval`이나 `arguments`를 이름으로 씁니다. ECMAScript의 엄격 모드와 그에 따르는 TypeScript가 어떤 선언도 허용하지 않는 이름입니다(규칙 2.1).

## 함께 보기

- [규칙 12.5](https://typeshade.dev/ko/reference/rules/12-5/) 테스트
- [규칙 12.7](https://typeshade.dev/ko/reference/rules/12-7/) 테스트
- [규칙 2.2](https://typeshade.dev/ko/reference/rules/2-2/)
- [규칙 6.7](https://typeshade.dev/ko/reference/rules/6-7/)
- [규칙 6.8](https://typeshade.dev/ko/reference/rules/6-8/)
- [규칙 7.1](https://typeshade.dev/ko/reference/rules/7-1/)
- [규칙 7.5](https://typeshade.dev/ko/reference/rules/7-5/)
- [규칙 8.5](https://typeshade.dev/ko/reference/rules/8-5/)
- [설계 규칙](https://typeshade.dev/ko/reference/rules/)
- [오류 코드](https://typeshade.dev/ko/reference/errors/)

## 소스

커밋 af54ddad5의 규칙 원문:

- [`docs/language-design.md:1758`](https://github.com/typeshade/typeshade/blob/af54ddad5/docs/language-design.md#L1758) (설계 문서)
- [`reqs/rules/RULE-1206.md`](https://github.com/typeshade/typeshade/blob/af54ddad5/reqs/rules/RULE-1206.md) (추적 항목)
