Rule 9.4
On this page

Rule 9.4

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

A Math member must lower to the WGSL builtin of the same meaning, and so must its free-function spelling where WGSL has a builtin of that name (sqrt, max; Rule 9.9 removed pow); a Math member with no WGSL builtin must be expanded into WGSL arithmetic, stays an ECMAScript name and has no free spelling; Math.fround(x) is f32(x). A Math member takes the scalar arguments ECMAScript gives it; the vector form of the same operation is the WGSL name. A name a const binds to a Math member, by an object pattern over Math or by the member itself, must mean that member: a call of it is the member’s call, and a constant member is its inlined literal; it takes the member’s signatures, and no function value exists for it.

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

Rationale

Derives from

MATH_FN_ALIAS and MATH_EXPAND_ALIAS in src/compiler/ts/math-alias.ts.

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:

surface-names.test.ts and src/compiler/ts/math-expand.test.ts; the scalar arguments by src/compiler/ts/math-scalar.test.ts (change 0112); the bound name by src/compiler/ts/math-binding.ts and math-binding.test.ts (change 0113).

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

Explained in

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

See also

Source

The rule at commit af54ddad5:

Edit this page Report a problem