---
title: "규칙 8.13: 함수와 진입점, TypeShade 셰이더 언어 설계 규칙과 그 근거, 출처, 검증 방식"
description: "TypeShade 언어 설계 규칙 8.13(함수와 진입점)입니다. A static field must be a module constant Owner_x when nothing in the program writes it…"
url: https://typeshade.dev/ko/reference/rules/8-13/
language: ko
---

# 규칙 8.13

8장, 함수와 진입점 테스트

A static field must be a module constant `Owner_x` when nothing in the program writes it, and a module variable in the per-invocation space ([Rule 6.5](https://typeshade.dev/ko/reference/rules/6-5/)) when something does; a `readonly` static is never written. A class inherits the statics of the classes it extends: `D.K`, `D.f()` and `D.x` reach the nearest class above `D` that declares them, and a static function or accessor `D` inherits must be lowered again for `D`. Inside a static member `this` is the class the call names, `D` in `D.f()`: `this.K`, `this.f()` and `this.x = v` name its statics, `new this(...)` builds it, and a static that returns the class the call names says so with a `this` parameter, `static make<C extends B>(this: { new (): C; K: f32 }): C`, which is a type and not a parameter anything passes, and returns `D`; `super.K`, `super.f()` and `super.x` name the statics of the class above the one that wrote the member. A write to a static field through a class that does not declare it (`D.K = v`, `this.K = v`, `super.K = v`), `this.#x` where `this` is a class that extends the one declaring `#x`, `this` as a value, a static block, and a static declared to return the class that declares it that builds its value with `new this(...)` where a class inherits it must be refused with the remedy; a write into such a static (`D.origin.y = v`, a method that changes it) changes the one object both classes read, and a generic base’s statics are its class’s, one for every instance.

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

## 근거

a static field that TypeScript code writes is state of the program’s run, which on the GPU is the invocation, so it is the variable a top-level `let` already is (surface §24); one no code writes folds as a top-level `const` does; a static block runs when a class is evaluated, and a shader has no such moment. TypeScript keeps statics on the constructor, whose prototype is its base’s constructor, so a read finds the nearest declaration, `this` in a static member is the constructor the call names, and a write through a derived constructor gives it a property of its own, which one module variable cannot be; a private static lives on its declaring constructor alone, so TypeScript throws where a derived class reaches it through `this`. TypeScript types a call by the return type the member writes, so a static that returns the class the call names writes that class as its `this` parameter’s construct signature, and one that writes the declaring class would be that class to the editor and `D` here ([Rule 12.7](https://typeshade.dev/ko/reference/rules/12-7/), proposal 0020).

## 출처

[Rule 6.3](https://typeshade.dev/ko/reference/rules/6-3/); [Rule 6.5](https://typeshade.dev/ko/reference/rules/6-5/); ECMAScript [ClassDefinitionEvaluation](https://tc39.es/ecma262/#sec-runtime-semantics-classdefinitionevaluation) (the constructor’s prototype is the base constructor) and [the `super` keyword](https://tc39.es/ecma262/#sec-super-keyword); [Variable and Value Declarations](https://gpuweb.github.io/gpuweb/wgsl/#var-and-value); surface §24 and §26.

## 검증 방식

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

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

`TS8035 CLASS_MEMBER` for a static block, for `this` as a value, for `this.#x` through a class that extends the one declaring it (`"Derived" has no "#k": a private static is the class's own, and TypeScript throws where a body "Derived" inherits reaches it through "this". Name the class that declares it, "Base.#k".`) and for `super.K = v`; `TS8005 CONST_ASSIGN` for a write to a `readonly` static and for one through a class that does not declare it (`"Derived.count" is a static "Base" declares, and assigning it through "Derived" would give "Derived" a copy of its own in TypeScript. Write "Base.count".`); `TS8035 CLASS_MEMBER` for `new this()` outside a static member; `TS8035 CLASS_MEMBER` for a static declared to return the class that declares it that builds its value with `new this()` where a class inherits it (`"Base.make" builds its value with "new this()", so "Derived.make()" returns a Derived, but it is declared to return a Base, which is the type the editor gives the call. Declare the class the call names: static make<C extends Base>(this: { new (): C; SCALE: f32 }): C`), pinned with the editor’s half by `src/compiler/ts/class-syntax.test.ts`; pinned by `src/compiler/ts/class-syntax.test.ts` and `src/compiler/ts/class-methods.test.ts`, which also hold the three CPU paths to one value for a static a derived class inherits and for `super` in a static member; `examples/gallery/class-builder/class-builder.shade.ts` in the compile gate.

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

- [`examples/shade-examples.test.ts:27`](https://github.com/typeshade/typeshade/blob/af54ddad5/examples/shade-examples.test.ts#L27)
- [`src/compiler/ts/class-methods.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/class-methods.test.ts#L1)
- [`src/compiler/ts/class-syntax.test.ts:419`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/class-syntax.test.ts#L419)
- [`src/compiler/ts/link.test.ts:4`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/link.test.ts#L4)

## 설명하는 절

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

- [§24 Module variables](https://github.com/typeshade/typeshade/blob/af54ddad5/docs/use-typeshade-surface.md#24-module-variables)
- [§26 Classes with methods, a constructor and static functions](https://github.com/typeshade/typeshade/blob/af54ddad5/docs/use-typeshade-surface.md#26-classes-with-methods-a-constructor-and-static-functions)
- [§68 Importing another shader module](https://github.com/typeshade/typeshade/blob/af54ddad5/docs/use-typeshade-surface.md#68-importing-another-shader-module)

## 적용하는 오류 코드

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

**[`TS8005`](https://typeshade.dev/ko/reference/errors/ts8005/) `CONST_ASSIGN`**

바뀔 수 없는 이름이나 자리에 값을 대입합니다. `const`에 담은 수나 벡터, `const` 벡터나 행렬의 성분, `readonly` 필드나 static, 그리고 `readonly`나 `"read"`로 쓰지 않겠다고 약속한 스토리지 바인딩에는 값을 쓸 수 없습니다. `const` 객체의 필드나 원소에 쓰는 것은 여기에 해당하지 않습니다. `const`는 객체를 담고 있을 뿐이고, 객체는 JavaScript에서처럼 계속 쓸 수 있기 때문입니다([규칙 6.10](https://typeshade.dev/ko/reference/rules/6-10/)).

**[`TS8035`](https://typeshade.dev/ko/reference/errors/ts8035/) `CLASS_MEMBER`**

표면이 받지 않는 클래스 멤버 모양, 클래스 규칙이 거부하는 멤버 사용, 클래스를 만들지 않는 `new`입니다(규칙 8.13). getter와 setter, static 필드와 메서드, 오버로드 시그니처, abstract 멤버, `#` 비공개 이름, 객체를 바꾸는 메서드는 모두 컴파일됩니다. 메시지가 멤버나 대상과 고칠 방법을 알려 줍니다.

## 함께 보기

- [규칙 8.12](https://typeshade.dev/ko/reference/rules/8-12/) 테스트
- [규칙 8.14](https://typeshade.dev/ko/reference/rules/8-14/) 테스트
- [규칙 6.3](https://typeshade.dev/ko/reference/rules/6-3/)
- [규칙 6.5](https://typeshade.dev/ko/reference/rules/6-5/)
- [규칙 12.7](https://typeshade.dev/ko/reference/rules/12-7/)
- [설계 규칙](https://typeshade.dev/ko/reference/rules/)
- [오류 코드](https://typeshade.dev/ko/reference/errors/)

## 소스

커밋 af54ddad5의 규칙 원문:

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