---
title: "규칙 9.2: 내장 함수와 TypeShade 확장, TypeShade 셰이더 언어 설계 규칙과 그 근거"
description: "TypeShade 언어 설계 규칙 9.2(내장 함수와 TypeShade 확장)입니다. A builtin's signature must be WGSL's, checked at the call."
url: https://typeshade.dev/ko/reference/rules/9-2/
language: ko
---

# 규칙 9.2

9장, 내장 함수와 TypeShade 확장 테스트

A builtin’s signature must be WGSL’s, checked at the call. The two recorded exceptions are `atan(y, x)` (WGSL’s `atan2`) and the ECMAScript arity of the `Math` members. A name of the `f64` family, which has no WGSL signature, must take the signatures WGSL gives the type it stands in for (`f64(x)` as `f32(x)`, `vecNf64` as WGSL’s vector constructors), and a further signature of one is a new name under [Rule 2.2](https://typeshade.dev/ko/reference/rules/2-2/).

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

## 근거

an argument shape Tint refuses should be refused at the source line, with the splat or the cast to write; and a signature is a spelling, so an overload that no WGSL form has is a spelling from nowhere (§2.1).

## 출처

[Numeric Built-in Functions](https://gpuweb.github.io/gpuweb/wgsl/#numeric-builtin-functions); [Value Constructor Built-in Functions](https://gpuweb.github.io/gpuweb/wgsl/#value-constructor-builtin-function) for the scalar and vector constructor forms; surface §10 ([#57](https://github.com/typeshade/typeshade/issues/57)), §39.

## 검증 방식

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

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

`TS8036 MATH_ARGUMENT` and `src/compiler/ts/lower/math-args.ts`, whose rule for a name with SUPPORTED `core.def` rows is derived from those rows (0017); [`TS8019`](https://typeshade.dev/ko/reference/errors/ts8019/) for `f64(a, b)` (`f64() expects 1 argument.`) and `surface-names.test.ts` (`the f64 family declares only the constructor forms WGSL gives the type it stands in for`, `the compiler refuses a second argument to f64`).

커밋 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/lower/math-args.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/lower/math-args.ts#L1)
- [`src/core/spec-conformance/surface-names.test.ts:50`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/core/spec-conformance/surface-names.test.ts#L50)

## 설명하는 절

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

- [§10 Builtins, casts and `discard`](https://github.com/typeshade/typeshade/blob/af54ddad5/docs/use-typeshade-surface.md#10-builtins-casts-and-discard)

## 적용하는 오류 코드

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

**[`TS8019`](https://typeshade.dev/ko/reference/errors/ts8019/) `ARITY_MISMATCH`**

호출이나 생성자에서 인자, 요소, 필드의 개수가 맞지 않습니다.

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

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

## 함께 보기

- [규칙 9.1](https://typeshade.dev/ko/reference/rules/9-1/) 테스트
- [규칙 9.3](https://typeshade.dev/ko/reference/rules/9-3/) 테스트
- [규칙 2.2](https://typeshade.dev/ko/reference/rules/2-2/)
- [설계 규칙](https://typeshade.dev/ko/reference/rules/)
- [오류 코드](https://typeshade.dev/ko/reference/errors/)

## 소스

커밋 af54ddad5의 규칙 원문:

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