---
title: "Rule 2.3: Sources of the surface, a TypeShade design rule"
description: "Rule 2.3 of the TypeShade language design, in Sources of the surface. A value sometimes has to cross between a representation the compiler chose and one the…"
url: https://typeshade.dev/reference/rules/2-3/
language: en
---

# Rule 2.3

Chapter 2, Sources of the surface Test

A value sometimes has to cross between a representation the compiler chose and one the target has: an `f64` and the two `f32` halves that carry it across an interface of `f32`. The compiler must either perform the bridge silently or refuse the program in one sentence naming an ordinary remedy. A spelling of the bridge, under any name, must not be a third option.

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

## Rationale

the two honest answers to “the target cannot take this as written” are to make it work or to say what to write instead; a third spelling the author has to learn is neither.

## Derives from

the same section of PR [#166](https://github.com/typeshade/typeshade/issues/166); the roadmap’s first rule, “ordinary TypeScript first”.

## 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:

- `TS8038 F64_ENTRY_IO` (`src/compiler/ts/lower/function.ts`, PR [#166](https://github.com/typeshade/typeshade/issues/166)) for an `f64` on an entry’s `@location` parameter, on an entry I/O struct field, or on an entry’s return, one sentence that names `f32(x)` and the uniform or storage binding as the two remedies (surface §39), pinned by `src/compiler/ts/f64-types.test.ts`;
- a [`TS8003`](https://typeshade.dev/reference/errors/ts8003/) that names no remedy, for an `f64` passed, returned, or assigned where an `f32` is declared (Appendix B);
- the surface-names test, which catches a spelling of the bridge that is a pre-emit id, a second signature of `f64`, or a non-constructor signature of a `vecNf64`, and the front end, which refuses a call of one;
- review, for a spelling under a new id, which none of the cases above catches.

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

- [`src/compiler/ts/f64-types.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/f64-types.test.ts#L1)
- [`src/compiler/ts/lower/function.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/lower/function.ts#L1)

## Explained in

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

- [§39 `f64`: the emulated double](https://github.com/typeshade/typeshade/blob/af54ddad5/docs/use-typeshade-surface.md#39-f64-the-emulated-double)

## Error codes that enforce it

The diagnostic codes the rule names under Enforced by, or whose registry text names the rule:

**[`TS8003`](https://typeshade.dev/reference/errors/ts8003/) `TYPE_MISMATCH`**

Two types that do not fit where they meet (an operator, a condition, a declaration, a return or an argument), a read of an optional value (`T | undefined`, `T | null` or `T | null | undefined`) that no test narrowed ([Rule 7.10](https://typeshade.dev/reference/rules/7-10/)), or a constant the compiler folds that WGSL refuses: a shift amount past 31, a divisor of 0, clamp bounds that cross, an `f32` past its range or a builtin call outside its domain, such as `Math.pow(-2., 2.)`.

**[`TS8038`](https://typeshade.dev/reference/errors/ts8038/) `F64_ENTRY_IO`**

An emulated double (`f64` or a `vec64`) on an entry's IO boundary: a `@location` parameter, a `@location` field of an IO struct or an entry's return. A double is a pair of `f32` words after lowering, and a varying interpolates each word on its own. Narrow with `f32(x)`, or read the double in the stage that needs it, since a uniform or a storage binding carries an `f64`.

## See also

- [Rule 2.2](https://typeshade.dev/reference/rules/2-2/) Test
- [Rule 2.4](https://typeshade.dev/reference/rules/2-4/) Test
- [Design rules](https://typeshade.dev/reference/rules/)
- [Error codes](https://typeshade.dev/reference/errors/)

## Source

The rule at commit af54ddad5:

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