---
title: "Rule 9.2: Built-in functions and the TypeShade extensions"
description: "Rule 9.2 of the TypeShade language design, in Built-in functions and the TypeShade extensions. A builtin's signature must be WGSL's, checked at the call."
url: https://typeshade.dev/reference/rules/9-2/
language: en
---

# Rule 9.2

Chapter 9, Built-in functions and the TypeShade extensions Test

A builtin’s signature must be WGSL’s, checked at the call. The two recorded exceptions are `atan(y, x)` (WGSL’s `atan2`) and the ECMAScript arity of the `Math` members. A name of the `f64` family, which has no WGSL signature, must take the signatures WGSL gives the type it stands in for (`f64(x)` as `f32(x)`, `vecNf64` as WGSL’s vector constructors), and a further signature of one is a new name under [Rule 2.2](https://typeshade.dev/reference/rules/2-2/).

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

## Rationale

an argument shape Tint refuses should be refused at the source line, with the splat or the cast to write; and a signature is a spelling, so an overload that no WGSL form has is a spelling from nowhere (§2.1).

## Derives from

[Numeric Built-in Functions](https://gpuweb.github.io/gpuweb/wgsl/#numeric-builtin-functions); [Value Constructor Built-in Functions](https://gpuweb.github.io/gpuweb/wgsl/#value-constructor-builtin-function) for the scalar and vector constructor forms; surface §10 ([#57](https://github.com/typeshade/typeshade/issues/57)), §39.

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

`TS8036 MATH_ARGUMENT` and `src/compiler/ts/lower/math-args.ts`, whose rule for a name with SUPPORTED `core.def` rows is derived from those rows (0017); [`TS8019`](https://typeshade.dev/reference/errors/ts8019/) for `f64(a, b)` (`f64() expects 1 argument.`) and `surface-names.test.ts` (`the f64 family declares only the constructor forms WGSL gives the type it stands in for`, `the compiler refuses a second argument to f64`).

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

- [`src/compiler/ts/array-minmax-types.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/array-minmax-types.test.ts#L1)
- [`src/compiler/ts/lower/math-args.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/lower/math-args.ts#L1)
- [`src/core/spec-conformance/surface-names.test.ts:50`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/core/spec-conformance/surface-names.test.ts#L50)

## Explained in

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

- [§10 Builtins, casts and `discard`](https://github.com/typeshade/typeshade/blob/af54ddad5/docs/use-typeshade-surface.md#10-builtins-casts-and-discard)

## Error codes that enforce it

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

**[`TS8019`](https://typeshade.dev/reference/errors/ts8019/) `ARITY_MISMATCH`**

A wrong number of arguments, elements or fields at a call or a constructor.

**[`TS8036`](https://typeshade.dev/reference/errors/ts8036/) `MATH_ARGUMENT`**

A math builtin called with arguments that its signature does not take: two shapes that had to agree (`dot(vec3, vec2)`), an element kind that the builtin has no form for (`sin` on an integer vector), a scalar where a vector is due (`normalize(s)`), or a factor, exponent, offset or count of the wrong type. The message names the offending argument and, where one is short, the fix: splat the scalar, cast one side, or give the vectors one size.

## See also

- [Rule 9.1](https://typeshade.dev/reference/rules/9-1/) Test
- [Rule 9.3](https://typeshade.dev/reference/rules/9-3/) Test
- [Rule 2.2](https://typeshade.dev/reference/rules/2-2/)
- [Design rules](https://typeshade.dev/reference/rules/)
- [Error codes](https://typeshade.dev/reference/errors/)

## Source

The rule at commit af54ddad5:

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