Rule 5.2
On this page

Rule 5.2

Chapter 5, Literals and typing Test

A written number beside a typed peer in an arithmetic operator or a builtin call must take the peer’s kind; a written number beside an f64 or an f64 vector must become an f64 literal carrying the full double.

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

Rationale

a literal has no type of its own until something states one, and the peer is the nearest statement.

Derives from

Overload Resolution; surface §13 (the min(1, i) edge).

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:

retargetLit in src/compiler/ts/numeric.ts (the lift is guarded on isF64(peer) || isVec64(peer), PR #166), so x + 0.1 and min(x, 0.1) on an x: f64 both carry the pair (0.10000000149011612, -1.4901161415892261e-9); src/compiler/ts/int-lit-coerce.test.ts and int-lit-context.test.ts (the min(1, i) case); src/compiler/ts/f64-types.test.ts (lifts a literal beside an f64 and a declared f64 const) for the double.

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

Explained in

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

See also

Source

The rule at commit 26de7be8:

Edit this page Report a problem