---
title: "규칙 4.6: 타입, TypeShade 셰이더 언어 설계 규칙과 그 근거, 출처, 검증 방식"
description: "TypeShade 언어 설계 규칙 4.6(타입)입니다. boolean written as a type must mean bool…"
url: https://typeshade.dev/ko/reference/rules/4-6/
language: ko
---

# 규칙 4.6

4장, 타입 테스트

`boolean` written as a type must mean `bool`, and `number` written as a type must mean that the type is inferred from its uses (OD-7); where no use decides, the type must be `f32`. Where TypeScript lets an annotation be omitted (a local, a result, a field, a list’s element, a parameter), `number` must read as if it were omitted, and an unannotated parameter, with or without a default, must mean the same as one written `number`. `f32`, `i32`, `u32` and `f64` must keep fixing a width. A parameter’s width must come from the places that call the function:

1. One call site, or call sites of one width: the parameter has the width of the values the calls pass.
2. Call sites of different widths: the function is compiled once for each set of widths the calls use, as a generic function is ([Rule 8.9](https://typeshade.dev/ko/reference/rules/8-9/), [Rule 3.9](https://typeshade.dev/ko/reference/rules/3-9/)); no call is refused for its width.
3. No call site: the parameter is `f32`.
4. An exported function: a call of it from any file of the program (Rule 3.9) is a call site and rules 1 to 3 apply; a call from outside the program is not read. A parameter of an entry point or a kernel function is inferred from the uses in its body only, and is `f32` where none decides.
5. A recursive function: the width of a parameter of a call cycle is the width the calls from outside the cycle pass, and the calls inside the cycle must agree with it or the cycle is compiled once for each such width (recursion itself stays under [Rule 8.4](https://typeshade.dev/ko/reference/rules/8-4/)).
6. A value whose uses in one function demand two widths, and a `number` that one use makes an integer and that `/` divides, must be refused as [Rule 5.1](https://typeshade.dev/ko/reference/rules/5-1/) refuses them.

A struct field, a class field and a field of a uniform or storage struct that is written `number` is decided from the places that assign or read it, and is `f32` where none decides.

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

## 근거

TypeScript accepts `number` and `boolean` (OD-12), and OD-7 removed the argument that `number` names no width: the compiler infers the width and chooses `f32` where no use decides.

## 출처

[Integer Types](https://gpuweb.github.io/gpuweb/wgsl/#integer-types), [Floating Point Types](https://gpuweb.github.io/gpuweb/wgsl/#floating-point-types), [Boolean Type](https://gpuweb.github.io/gpuweb/wgsl/#bool-type); `changes/0159-number-and-boolean-written-as-types.md`.

## 검증 방식

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

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

`src/compiler/ts/number-types.test.ts`.

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

- [`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/number-types.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/number-types.test.ts#L1)

## 설명하는 절

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

- [§28 What TypeScript writes that the GPU has no word for](https://github.com/typeshade/typeshade/blob/af54ddad5/docs/use-typeshade-surface.md#28-what-typescript-writes-that-the-gpu-has-no-word-for)

## 함께 보기

- [규칙 4.5](https://typeshade.dev/ko/reference/rules/4-5/) 테스트
- [규칙 4.7](https://typeshade.dev/ko/reference/rules/4-7/) 테스트
- [규칙 3.9](https://typeshade.dev/ko/reference/rules/3-9/)
- [규칙 5.1](https://typeshade.dev/ko/reference/rules/5-1/)
- [규칙 8.4](https://typeshade.dev/ko/reference/rules/8-4/)
- [규칙 8.9](https://typeshade.dev/ko/reference/rules/8-9/)
- [설계 규칙](https://typeshade.dev/ko/reference/rules/)
- [오류 코드](https://typeshade.dev/ko/reference/errors/)

## 소스

커밋 af54ddad5의 규칙 원문:

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