DEVELOPMENT EDITION · 769442725406
Diagnostics Reference
On this page

B0004: malformed numeric literal

Catalog status: active. Default severity: error. Stable name: malformed-number. Family: Syntax and source text.

A numeric literal breaks one of Ada's rules (RM 2.4): underscores must separate digits singly, a based literal needs a base from 2 to 16 and digits valid in that base between two #, and an integer literal cannot have a negative exponent.

Example (Vada)

   Mask  : constant := 16#FG#;   --  G is not a hexadecimal digit
   Count : constant := 1__000;   --  doubled underscore
   Ratio : constant := 1E-3;     --  an integer literal with a negative exponent

Example (Varc)

    let mask = 0xFG;     // G is not a hexadecimal digit
    let count = 1__000;  // doubled underscore
    let ratio = 1e-3;    // an integer literal with a negative exponent

What to do (Vada)

Fix the literal: 16#FF#, 1_000, and 1.0E-3 (a real literal) for the examples above.

What to do (Varc)

Fix the literal: 0xFF, 1_000, and 1.0e-3 (a real literal) for the examples above.

Regression source and further reading

Complete regression example: source, command arguments and expected results. The fixture deliberately reproduces this diagnostic.

See syntax and source text, the code index, and diagnostic interpretation for modes, replay, fix-its and JSON.