rune icon indicating copy to clipboard operation
rune copied to clipboard

Wrong diagnosis of number literal out of bounds when using a bit mask

Open rnd-ash opened this issue 1 year ago • 1 comments

As rune forces me to use signed integer types, the compiler will emit an error when trying to use a bitmask on an integer:

Code:

value & 0xff00_0000_0000_0000) >> 0x38

Error:

error: Number literal out of bounds `-9223372036854775808` to `9223372036854775807`
   ┌─ entry:67:17
   │
67 │         (value & 0xff00_0000_0000_0000) >> 0x38 |
   │                 ^^^^^^^^^^^^^^^^^^^^^ Number literal out of bounds `-9223372036854775808` to `9223372036854775807

Is there a way to disable this literal check?

rnd-ash avatar Mar 15 '24 15:03 rnd-ash

Can't be disabled, but I'm also not sure if we should. Since this matches the behavior of Rust.

In the future I do want to support other integer types, and this would be a valid u64 literal.

udoprog avatar Mar 15 '24 16:03 udoprog