---
title: "규칙 11.27: 대상과 오라클, TypeShade 셰이더 언어 설계 규칙과 그 근거, 출처, 검증 방식"
description: "TypeShade 언어 설계 규칙 11.27(대상과 오라클)입니다. A function of an emitted module must hold no constant expression that its target refuses to evaluate…"
url: https://typeshade.dev/ko/reference/rules/11-27/
language: ko
---

# 규칙 11.27

11장, 대상과 오라클 테스트

A function of an emitted module must hold no constant expression that its target refuses to evaluate, or evaluates to another value than the operation has at run time: the pass that settles constant expressions binds an operand of such an operation to a `let`, and the operation is evaluated when the shader runs.

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

## 근거

WGSL evaluates a constant expression when it creates the shader and makes one outside a builtin’s domain or past the range of its type an error; the compiler can give such an operation its run-time value by evaluating it when the shader runs, so the form is not refused (OD-9), whether the author wrote the constants in the call or passed them through a helper, and the same source does not compile or fail by optimization level. A WebGL2 driver accepts such an expression and folds it to a value of its own (`pow(-2.0, 2.0)` to 0).

## 출처

`changes/0156-optimizer-makes-no-refused-constant.md` (P1 to P5, amendment A1); [#368](https://github.com/typeshade/typeshade/issues/368); [#613](https://github.com/typeshade/typeshade/issues/613); [#1789](https://github.com/typeshade/typeshade/issues/1789); [#1876](https://github.com/typeshade/typeshade/issues/1876); OD-3; OD-9.

## 검증 방식

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

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

`settleConstExprs` (`src/core/passes/const-expr.ts`) and `constFold` (`src/core/passes/opt/const-fold.ts`), pinned by `src/core/passes/const-bind.test.ts` (each class of the scope table, and what stays unbound), `src/core/passes/const-bind-emit.test.ts` (each emit path) and `src/core/backends/glsl-const-bind.test.ts` (the operand in a local on GLSL ES 3.00); both halves read the helper forms and the twelve forms of [#1876](https://github.com/typeshade/typeshade/issues/1876) in `src/compiler/ts/const-bind-forms.test.ts`, and the refusals that stay in `src/compiler/ts/const-bind-refusals.test.ts`; the const-bind leg of `scripts/compile-gate.ts` judges the programs on Tint and WebGL2 and hands Tint the text that the baseline emitted for each class ([Rule 13.3](https://typeshade.dev/ko/reference/rules/13-3/)).

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

- [`scripts/compile-gate.ts:134`](https://github.com/typeshade/typeshade/blob/af54ddad5/scripts/compile-gate.ts#L134)
- [`src/compiler/ts/const-bind-forms.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/const-bind-forms.test.ts#L1)
- [`src/compiler/ts/const-bind-refusals.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/const-bind-refusals.test.ts#L1)
- [`src/core/backends/glsl-const-bind.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/core/backends/glsl-const-bind.test.ts#L1)
- [`src/core/passes/const-bind-emit.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/core/passes/const-bind-emit.test.ts#L1)
- [`src/core/passes/const-bind.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/core/passes/const-bind.test.ts#L1)
- [`src/core/passes/const-bind.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/core/passes/const-bind.ts#L1)
- [`src/core/passes/const-expr.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/core/passes/const-expr.ts#L1)
- [`src/core/passes/opt/const-fold.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/core/passes/opt/const-fold.ts#L1)

## 함께 보기

- [규칙 11.23](https://typeshade.dev/ko/reference/rules/11-23/) 테스트
- [규칙 12.1](https://typeshade.dev/ko/reference/rules/12-1/) 테스트
- [규칙 13.3](https://typeshade.dev/ko/reference/rules/13-3/)
- [설계 규칙](https://typeshade.dev/ko/reference/rules/)
- [오류 코드](https://typeshade.dev/ko/reference/errors/)

## 소스

커밋 af54ddad5의 규칙 원문:

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