---
title: "규칙 8.1: 함수와 진입점, TypeShade 셰이더 언어 설계 규칙과 그 근거, 출처, 검증 방식"
description: "TypeShade 언어 설계 규칙 8.1(함수와 진입점)입니다. An entry point is a function declaration at the top of the file or of a namespace, exported or not…"
url: https://typeshade.dev/ko/reference/rules/8-1/
language: ko
---

# 규칙 8.1

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

An entry point is a function declaration at the top of the file or of a namespace, exported or not, with exactly one stage attribute written before the declaration: `@vertex export function vs(…)`, `@fragment …`, or `@compute([x, y?, z?]) …`. The order `export @vertex function` is accepted and means the same. An entry takes its declaration’s name, so `export default` on an entry must be refused with [`TS8028`](https://typeshade.dev/ko/reference/errors/ts8028/) (“an entry takes its declaration’s name; write `export function k`”) (change 0130, D4, as amended by change 0140). A bare `@compute` and `@compute()` take the default size ([Rule 8.7](https://typeshade.dev/ko/reference/rules/8-7/)). `@vertex` and `@fragment` take no argument list: `@vertex()` and an argument on either must be refused with `TS8028`. An entry written as a `const`, an arrow function or a function expression, and an entry method on a class, must be refused; the stage calls of change 0111 are refused ([Rule 6.7](https://typeshade.dev/ko/reference/rules/6-7/)).

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

## 근거

`this` is not a GPU instance, and an entry has no receiver. The stage marks the function, so it is the language’s attribute on the declaration ([Rule 1.8](https://typeshade.dev/ko/reference/rules/1-8/)).

## 출처

[Entry Points](https://gpuweb.github.io/gpuweb/wgsl/#entry-points); change `0111` (D1, replaced by change `0130`); change `0130`; change `0140`; surface §3 and §4.

## 검증 방식

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

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

the front end’s entry reading in `src/compiler/ts/source-file.ts` and `decorated-form.ts`, pinned by `src/compiler/ts/stage3.test.ts` (both orders, a namespace entry, two stage attributes refused, an argument on `@vertex` or `@fragment` refused in both halves with [`TS8028`](https://typeshade.dev/ko/reference/errors/ts8028/), `"@vertex" takes no argument: write "@vertex" and delete "(1)" (Rule 8.1).`, the empty argument list, `@vertex()` or `@fragment()`, refused with the same sentence and `delete "()"` while `@compute()` stays accepted (change 0130, amendment A1), a type argument on a stage attribute or on `@workgroup_size` refused as a decorator that is not a name is ([Rule 6.7](https://typeshade.dev/ko/reference/rules/6-7/)), `export default` refused on `default` in both halves), `src/compiler/ts/stage-call.test.ts` (an entry written as a `const`, an arrow function or a function expression through a stage call, refused in both halves) and `src/language-service/new-entry-forms.test.ts`; [`TS8035`](https://typeshade.dev/ko/reference/errors/ts8035/) (`A decorator has no place on "C.k"; an entry is a function declaration with a stage attribute, "@vertex export function vs(…) { … }".`), beside surface §7’s row “`@compute` method on a class”.

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

- [`src/compiler/ts/class-syntax-example.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/class-syntax-example.test.ts#L1)
- [`src/compiler/ts/class-syntax.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/class-syntax.test.ts#L1)
- [`src/compiler/ts/source-file.ts:2`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/source-file.ts#L2)
- [`src/compiler/ts/stage-call.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/stage-call.test.ts#L1)
- [`src/compiler/ts/stage-call.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/stage-call.ts#L1)
- [`src/compiler/ts/stage3.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/stage3.test.ts#L1)
- [`src/language-service/new-entry-forms.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/language-service/new-entry-forms.test.ts#L1)

## 설명하는 절

커밋 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)
- [§7 Diagnostics (required)](https://github.com/typeshade/typeshade/blob/af54ddad5/docs/use-typeshade-surface.md#7-diagnostics-required)

## 적용하는 오류 코드

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

**[`TS8028`](https://typeshade.dev/ko/reference/errors/ts8028/) `ATTRIBUTE_NAME`**

이 표면이 읽지 않는 데코레이터나 진입점 형태입니다. 속성 어휘(`@vertex`, `@fragment`, `@compute`, `@builtin`, `@location`) 밖의 식별자(`@vertx` 같은 오타), 표면이 다른 방식으로 쓰거나 빌려 오지 않는 WGSL 속성(직접 쓴 `@diagnostic(…)` 같은 것), `vertex(f)`처럼 호출로 쓴 스테이지, `export default`처럼 규칙 8.1이 거부하는 형태로 쓴 진입점, 데코레이터를 받지 않는 선언이나 자리에 붙은 데코레이터가 그렇습니다([규칙 6.7](https://typeshade.dev/ko/reference/rules/6-7/)). 이 코드가 없으면 데코레이터를 붙인 함수나 필드가 아무 말 없이 진입점이나 IO 필드가 아니게 됩니다.

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

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

## 함께 보기

- [규칙 7.10](https://typeshade.dev/ko/reference/rules/7-10/) 테스트
- [규칙 8.2](https://typeshade.dev/ko/reference/rules/8-2/) 테스트
- [규칙 1.8](https://typeshade.dev/ko/reference/rules/1-8/)
- [규칙 6.7](https://typeshade.dev/ko/reference/rules/6-7/)
- [규칙 8.7](https://typeshade.dev/ko/reference/rules/8-7/)
- [설계 규칙](https://typeshade.dev/ko/reference/rules/)
- [오류 코드](https://typeshade.dev/ko/reference/errors/)

## 소스

커밋 af54ddad5의 규칙 원문:

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