Skip to content

[regression] VM: Error: cannot convert -1 to uint64 #13661

@timotheecour

Description

@timotheecour

VM doesn't handle properly uint64 with high bit set (except when from a literal).

Example

proc fun(): uint = cast[uint](-1)
const x0 = fun()
discard $x0 # Error: cannot convert -1 to uint64; ditto with echo x0

const x1 = cast[uint](-1)
discard $x1 # ditto

# workaround (not a real workaround since we can't get the string at CT)
let x0b = x0
discard $x0b # this works

const x2 = 18446744073709551615'u
discard $x2 # works in devel, CT error 0.20.2: Error: number out of range: '18446744073709551615'u'

Current Output

Error: cannot convert -1 to uint64

Expected Output

works

Additional Information

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