---
title: "Rule 11.12: Targets and the oracle, a TypeShade design rule"
description: "Rule 11.12 of the TypeShade language design, in Targets and the oracle."
url: https://typeshade.dev/reference/rules/11-12/
language: en
---

# Rule 11.12

Chapter 11, Targets and the oracle Test

An integer division, remainder and shift, and a float’s conversion to an integer, must give WGSL’s answer on GLSL ES 3.00 for every input WGSL settles: the GLSL writer spells each through a helper that settles the inputs GLSL ES 3.00 leaves undefined, and uses the bare operator only where the operands cannot reach one.

The rule text and the parts under it are the compiler's own English, as the design document writes them.

## Rationale

GLSL ES 3.00 gives a zero divisor, the least `int` over -1, a negative operand of `%`, a shift amount past the width and a float the integer cannot hold no result (its §5.9, §4.1.3 and §5.4.1), and a WebGL2 driver answers otherwise than WGSL on all but the shift ([#382](https://github.com/typeshade/typeshade/issues/382)); the oracle follows WGSL ([Rule 11.5](https://typeshade.dev/reference/rules/11-5/)), so without the helpers a program means one thing on WebGPU and on the CPU tier and another on WebGL2, a kernel function’s WebGL2 tier included.

## Derives from

change `0027` in `changes/`; [#382](https://github.com/typeshade/typeshade/issues/382); [Arithmetic Expressions](https://gpuweb.github.io/gpuweb/wgsl/#arithmetic-expr), [Bit Expressions](https://gpuweb.github.io/gpuweb/wgsl/#bit-expr) and [Conversion Expressions](https://gpuweb.github.io/gpuweb/wgsl/#conversion-expr).

## How it is verified

Checked by a test. A test, a gate script or a CI workflow names this rule, and the traceability check fails when a file listed below stops naming it.

Where the rule says the compiler enforces it:

`src/core/backends/glsl-int.ts`, which the GLSL writer’s `intBinop` and `floatToInt` spellings call; pinned by `src/core/backends/glsl-int-answers.test.ts` on both halves; the compile gate for every example’s GLSL; and the WebGL2 arm of `scripts/gpu-differential.ts`, which holds these operations to the oracle over generated programs and requires the corpus to reach the inputs GLSL leaves undefined.

The files that verify it at commit af54ddad5, each at the first line that names the rule:

- [`scripts/gpu-differential.ts:36`](https://github.com/typeshade/typeshade/blob/af54ddad5/scripts/gpu-differential.ts#L36)
- [`src/core/backends/glsl-int-answers.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/core/backends/glsl-int-answers.test.ts#L1)
- [`src/core/backends/glsl-int.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/core/backends/glsl-int.ts#L1)

## Explained in

The sections of the surface document that explain this rule, at commit af54ddad5:

- [§11 Vector constructors](https://github.com/typeshade/typeshade/blob/af54ddad5/docs/use-typeshade-surface.md#11-vector-constructors)
- [§22 Constant checks on a shift amount and a divisor](https://github.com/typeshade/typeshade/blob/af54ddad5/docs/use-typeshade-surface.md#22-constant-checks-on-a-shift-amount-and-a-divisor)

## See also

- [Rule 11.11](https://typeshade.dev/reference/rules/11-11/) Test
- [Rule 11.13](https://typeshade.dev/reference/rules/11-13/) Test
- [Rule 11.5](https://typeshade.dev/reference/rules/11-5/)
- [Design rules](https://typeshade.dev/reference/rules/)
- [Error codes](https://typeshade.dev/reference/errors/)

## Source

The rule at commit af54ddad5:

- [`docs/language-design.md:1569`](https://github.com/typeshade/typeshade/blob/af54ddad5/docs/language-design.md#L1569) (the design document)
- [`reqs/rules/RULE-1112.md`](https://github.com/typeshade/typeshade/blob/af54ddad5/reqs/rules/RULE-1112.md) (its traceability item)
