---
title: "TS8033 MODULE_VAR: TypeShade 컴파일러가 진단에 붙이는 오류 코드와 그 뜻, 고치는 법"
description: "TS8033 MODULE_VAR, TypeShade 컴파일러의 오류 코드입니다. 주소 공간이 허용하지 않는 곳에서 모듈 변수를 선언하거나 씁니다."
url: https://typeshade.dev/ko/reference/errors/ts8033/
language: ko
---

# `TS8033`

프런트엔드 코드 `MODULE_VAR`

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

레지스트리에는 이 상수에 대한 문서 주석이 없습니다. 그래서 위 설명은 컴파일러가 이 코드와 함께 내는 메시지를 보고 이 사이트가 쓴 것입니다.

레지스트리 설명과 컴파일러 메시지는 컴파일러 원문이라 한국어 페이지에서도 영어로 둡니다.

## 예제

example.shade.ts

```ts
"use typeshade"

let tile: workgroup<array<f32, 64>>

@fragment
export function main(uv: location<0, vec2>): vec4 {
  return vec4(uv, tile[0], 1.)
}
```

빌드할 때 고정된 컴파일러로 이 프로그램을 컴파일하면 다음 진단이 나옵니다.

**TS8033** error, 7행: "tile" is workgroup memory, which only a compute entry has; a fragment entry cannot read or write it.

## 고치는 법

같은 프로그램을 고친 모습입니다. 진단 없이 컴파일됩니다.

example.shade.ts

```ts
"use typeshade"

let tile: array<f32, 64>

@fragment
export function main(uv: location<0, vec2>): vec4 {
  return vec4(uv, tile[0], 1.)
}
```

## 이 코드가 적용하는 규칙

**[규칙 6.1](https://typeshade.dev/ko/reference/rules/6-1/) 테스트**

A resource must be written `declare const x: uniform<T>`, `declare const x: storage<T>`, `declare const x: storage<T, "read_write">`, or `declare const x: <texture or sampler type>`.

**[규칙 6.5](https://typeshade.dev/ko/reference/rules/6-5/) 테스트**

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`.

**[규칙 8.3](https://typeshade.dev/ko/reference/rules/8-3/) 테스트**

A builtin WGSL confines by stage may be used in an entry of a permitted stage, and in a helper that no entry of an excluded stage can reach.

## 함께 보기

- [리소스](https://typeshade.dev/ko/guide/language/resources/)
- [오류 코드](https://typeshade.dev/ko/reference/errors/)

## 소스

커밋 af54ddad5에서 컴파일러가 이 코드를 내는 곳입니다. 파일마다 한 줄씩 적었습니다.

- [`src/compiler/ts/lower/expression/identifier.ts:134`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/lower/expression/identifier.ts#L134)
- [`src/compiler/ts/module-vars.ts:64`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/module-vars.ts#L64)
- [`src/compiler/ts/stage-restrictions.ts:108`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/stage-restrictions.ts#L108)
- [`src/compiler/ts/type-map.ts:912`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/type-map.ts#L912)
- [`src/language-service/diagnostics/same-mistake-spans.ts:137`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/language-service/diagnostics/same-mistake-spans.ts#L137)
