Skip to content

Invalid number parsing for unsigned 64-bit integers > 2**63 - 1 (tkUInt64Lit not in case statement at end of GetNumber proc in compiler/lexer.nim) #723

@boydgreenfield

Description

@boydgreenfield

Currently, unsigned 64-bit integers larger than 2**63 - 1 (the max value of a signed 64-bit integer) raises an error, e.g., "Error: 9223372036854775798 is not a valid number".

I believe this relates to the lack of a tkUInt64Lit type in the case statement at the end of the GetNumber proc in compiler/lexer.nim, and specifically the code path starting at line ~392.

The following code demonstrates the bug:

let w = 9223372036854775798'i64  # 2*63 - 1. Works as expected.
echo(w)
let x = 2147483647'i32  # 2**31 - 1
echo(x)
let y = 2147483647'u64  # 2**31 - 1
echo(y)
let z = 2147483648'u64  # Any number > 2**31 - 1 raises an error.
echo(z)

Note: This relates to the same code as discussed in issue #572 .

I will also attempt to patch and submit a PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions