Rule 5.5
On this page

Rule 5.5

Chapter 5, Literals and typing Test

A single float-written literal valued as a whole number may take a declared integer type in a declaration only; a return, an argument, and a field must not take that carve-out.

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

Rationale

the carve-out predates the integer rule and was kept so that programs did not break; extending it would make 1e3 an integer in places where it never was.

Derives from

surface §13.

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/compiler/ts/int-lit-context.test.ts, which covers the ten declared positions.

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