---
title: "TS8017 SWITCH_CASE: TypeShade 컴파일러가 진단에 붙이는 오류 코드 한 가지"
description: "TS8017 SWITCH_CASE, TypeShade 컴파일러의 오류 코드입니다. 잘못된 switch case입니다. 정수 상수가 아니거나 셀렉터에 맞지 않거나 다른 레이블과 겹치는 레이블, 함께 쓸 본문이 아래에 없는 빈 절…"
url: https://typeshade.dev/ko/reference/errors/ts8017/
language: ko
---

# `TS8017`

프런트엔드 코드 `SWITCH_CASE`

잘못된 `switch` case입니다. 정수 상수가 아니거나 셀렉터에 맞지 않거나 다른 레이블과 겹치는 레이블, 함께 쓸 본문이 아래에 없는 빈 절, 본문이 있는 절 위에서 끝에 닿을 수 있는 본문(TypeScript는 다음 절로 넘어가지만 WGSL은 그렇지 않습니다, [규칙 7.3](https://typeshade.dev/ko/reference/rules/7-3/)), 그리고 루프가 감싸지 않은 switch 안의 `continue`가 그렇습니다.

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

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

## 예제

example.shade.ts

```ts
"use typeshade"

@fragment
export function main(uv: location<0, vec2>): vec4 {
  let g = 0.
  switch (i32(uv.x * 4.)) {
    case 0: g = 0.25; break
    case 0: g = 0.5; break
    default: g = 1.
  }
  return vec4(g, g, g, 1.)
}
```

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

**TS8017** error, 8행: Duplicate switch case 0; each label may appear once.

## 고치는 법

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

example.shade.ts

```ts
"use typeshade"

@fragment
export function main(uv: location<0, vec2>): vec4 {
  let g = 0.
  switch (i32(uv.x * 4.)) {
    case 0: g = 0.25; break
    case 1: g = 0.5; break
    default: g = 1.
  }
  return vec4(g, g, g, 1.)
}
```

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

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

An empty `switch` case directly above a case with a body is one clause with several selectors (`case 0: case 1:` is WGSL’s `case 0, 1:`); an empty case with no case below it or directly above `default:`, and an empty `default:` with a case after it, must be refused; a case body must not fall through into the body of a case below it.

## 함께 보기

- [제어 흐름](https://typeshade.dev/ko/guide/language/control-flow/)
- [오류 코드](https://typeshade.dev/ko/reference/errors/)

## 소스

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

- [`src/compiler/ts/lower/control/switch.ts:52`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/lower/control/switch.ts#L52) (10곳)
