Skip to main content

W0043 - Non-standard integer formatting

This diagnostic is experimental and disabled by default. Enable it via [linters.nonstandard_integer_formatting] enabled = true and either experimental = false or the --experimental flag, in the project's .elp_lint.toml.

Warning​

fn() ->
1000000.
%% ^^^^^^^ 💡 information: Non-standard integer formatting
fn() ->
16#12AFBC31FF629986.
%% ^^^^^^^^^^^^^^^^^^^ 💡 information: Non-standard integer formatting

Explanation​

Long integer literals without separators for readability, or with separators in non-standard locations can be error-prone to read.

To fix, add underscores to break the integer literal up into readable chunks.

fn() ->
1_000_000.
fn() ->
16#12AF_BC31_FF62_9986.

Known limitations​

The linter rewrites every base 2, 10 and 16 literal into a single canonical form, without regard for what the number means:

  • Decimal literals with four or more digits are grouped in thousands, including years (2026 becomes 2_026), ports (8080 becomes 8_080), dates (20261102 becomes 20_261_102) and times of day (235959 becomes 235_959).
  • Existing underscores are discarded, so intentional groupings are lost: 2026_11_02 becomes 20_261_102, and a binary literal grouped by bit field, such as 2#101_10110, becomes 2#1011_0110.
  • Hexadecimal and binary literals are grouped in fours, so a colour such as 16#FFFFFF becomes 16#FF_FFFF.
  • Lowercase hexadecimal digits are reported and uppercased: 16#ff becomes 16#FF.
  • Leading zeros are removed: 0100 becomes 100.