---
title: "규칙 6.5: 선언과 리소스, TypeShade 셰이더 언어 설계 규칙과 그 근거, 출처, 검증 방식"
description: "TypeShade 언어 설계 규칙 6.5(선언과 리소스)입니다. A top-level let is a module variable in the per-invocation (private) address space…"
url: https://typeshade.dev/ko/reference/rules/6-5/
language: ko
---

# 규칙 6.5

6장, 선언과 리소스 테스트

A top-level `let` is a module variable in the per-invocation (`private`) address space; workgroup memory must be written `let x: workgroup<T>`; a module variable must take no `declare`. A sized array in workgroup memory may use a scalar integer override as its outer element count; its default is the count used by the CPU oracle, and the selected override specializes the WGSL array.

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

## 근거

a module-level `let` already says “a value this invocation owns”, so the address space is read off the syntax and only the space TypeScript cannot express gets a wrapper.

## 출처

[Address Spaces](https://gpuweb.github.io/gpuweb/wgsl/#address-space); surface §24; the roadmap’s first rule.

## 검증 방식

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

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

`TS8033 MODULE_VAR` and `src/compiler/ts/module-vars.test.ts`.

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

- [`src/compiler/ts/module-vars-atomic.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/module-vars-atomic.test.ts#L1)
- [`src/compiler/ts/module-vars.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/module-vars.test.ts#L1)

## 설명하는 절

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

- [§24 Module variables](https://github.com/typeshade/typeshade/blob/af54ddad5/docs/use-typeshade-surface.md#24-module-variables)

## 적용하는 오류 코드

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

**[`TS8033`](https://typeshade.dev/ko/reference/errors/ts8033/) `MODULE_VAR`**

주소 공간이 허용하지 않는 곳에서 모듈 변수를 선언하거나 씁니다. 주소 공간 래퍼가 붙은 `const`, 초기값이 있는 `workgroup` 변수, 그 공간이 담을 수 없는 타입(텍스처, 런타임 크기 배열, 호출별 변수 안의 atomic), 상수가 아닌 초기값, 정점이나 프래그먼트 진입점이 닿는 `workgroup` 변수가 그렇습니다. 일반 최상위 `let`이 대신하게 된 `perInvocation<T>` 래퍼도 여기에 속합니다.

## 함께 보기

- [규칙 6.4](https://typeshade.dev/ko/reference/rules/6-4/) 테스트
- [규칙 6.6](https://typeshade.dev/ko/reference/rules/6-6/) 테스트
- [설계 규칙](https://typeshade.dev/ko/reference/rules/)
- [오류 코드](https://typeshade.dev/ko/reference/errors/)

## 소스

커밋 af54ddad5의 규칙 원문:

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