---
title: "규칙 2.2: 표면 이름의 출처, TypeShade 셰이더 언어 설계 규칙과 그 근거, 출처, 검증 방식"
description: "TypeShade 언어 설계 규칙 2.2(표면 이름의 출처)입니다. A compiler-internal name (§2.1) must not be authorable."
url: https://typeshade.dev/ko/reference/rules/2-2/
language: ko
---

# 규칙 2.2

2장, 표면 이름의 출처 테스트

A compiler-internal name (§2.1) must not be authorable. It must not be declared in the ambient library, as a name, as a signature or an overload of an allowed name, or as a member of an allowed type. It must not be given a row of §9.3, under its own id or under any other spelling of the same thing.

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

## 근거

an internal helper is a contract between two passes, and an author who can write it can also write it wrong, with no specification to say what wrong means.

## 출처

the same section of PR [#166](https://github.com/typeshade/typeshade/issues/166), written on the `f64FromParts` case (§2.4).

## 검증 방식

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

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

- `surface-names.test.ts` (`no pre-emit intrinsic id is declared or listed`), which asserts that every id of `PRE_EMIT_INTRINSICS` other than the type name `f64` is neither declared in `SHADE_DTS` nor a row of `TYPESHADE_EXTENSIONS`;
- the same test (`reports an internal helper by name when one reaches the surface`), for the sentence a stray declaration gets;
- the same test (`the front end resolves no pre-emit id as a builtin`), for the call route, since `resolveMathFn` in `src/compiler/ts/math-alias.ts` resolves an alias only when `isKnownIntrinsic` accepts its id, exempting `f32`, `atan2`, and `mod`, none of which is pre-emit, so `f64Parts(x)` in a shader is `TS8004 Unknown function`;
- the same test’s first case, which catches a generated backend name that is declared, as a stray;
- the same test (`the f64 family declares only the constructor forms WGSL gives the type it stands in for`), for the overload route, which pins every declared signature of `f64` to one argument and every signature of `vec2f64`, `vec3f64`, and `vec4f64` to WGSL’s vector constructor forms (a splat, N components, or a narrower `f64` vector plus components);
- that same case, which reports `f64(hi: f32, lo: f32)` appended to the library;
- the same test (`the compiler refuses a second argument to f64`), for the call route of the same overload, `TS8019 f64() expects 1 argument.`;
- the call route of the IR builder’s `.swizzle()`, which no call reaches by its name since proposal 0008: `v.swizzle("yxz")` is [`TS8022`](https://typeshade.dev/ko/reference/errors/ts8022/), a member the vector does not have, which names the member it is written as, `v.yxz`, pinned by `src/compiler/ts/swizzle-random.test.ts`;
- review under §2.1’s definition ([Rule 9.8](https://typeshade.dev/ko/reference/rules/9-8/)), since a name that denotes an internal representation under an id outside `PRE_EMIT_INTRINSICS` passes every case of the test once it has a row.

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

- [`src/compiler/ts/math-alias.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/math-alias.ts#L1)
- [`src/compiler/ts/swizzle-random.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/swizzle-random.test.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의 언어 문서에서 이 규칙을 설명하는 절입니다.

- [§17 What a `for` loop may say, and what it is told](https://github.com/typeshade/typeshade/blob/af54ddad5/docs/use-typeshade-surface.md#17-what-a-for-loop-may-say-and-what-it-is-told)
- [§76 Optional values: `T | undefined`, `T | null` and three states](https://github.com/typeshade/typeshade/blob/af54ddad5/docs/use-typeshade-surface.md#76-optional-values-t--undefined-t--null-and-three-states)

## 적용하는 오류 코드

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

**[`TS8004`](https://typeshade.dev/ko/reference/errors/ts8004/) `UNKNOWN_FN`**

파일이 선언하지도 가져오지도 않은 함수를 부르거나, ECMAScript 표기가 있어서 언어에서 뺀 내장 함수를 부릅니다. `arrayLength(xs)`가 그 예이며, 메시지가 대신 쓸 `xs.length`를 알려 줍니다([규칙 9.9](https://typeshade.dev/ko/reference/rules/9-9/)).

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

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

**[`TS8022`](https://typeshade.dev/ko/reference/errors/ts8022/) `UNKNOWN_NAME`**

TypeShade가 풀지 못하는 이름을 가리킵니다. 함수 호출(`UNKNOWN_FN`)이나 타입 이름(`UNKNOWN_TYPE`)은 아닙니다. 라이브러리가 TypeScript 자체를 위해 선언한 이름(`Object`, `Math`, `Symbol`)이나 파일이 enum, 네임스페이스, 클래스, 타입으로 선언한 이름을 값으로 읽으면, 메시지가 그 이름이 무엇인지 알려 줍니다.

## 함께 보기

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

## 소스

커밋 af54ddad5의 규칙 원문:

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