-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Closed
Labels
Description
Compilation fails when tuples containing high-bit uint64 are assigned to consts. This is the case with literals and also with calculation (which is how I ran into it). It's not true of smaller integer sizes.
Example
var ok1: (uint64, array[1 .. 2, int]) = block:
var b: array[1 .. 2, int]
(0x8000_0000_0000_0000'u64, b)
var ok2: (seq[uint64], uint64) = block:
var x: seq[uint64]
x.add 0x8000_0000_0000_0000'u64
(x, 0'u64)
var ok3: (char, uint64) = block:
('.', 1'u64 + 0x7FFF_FFFF_FFFF_FFFF'u64)
const ok4: array[1, uint64] = block:
var b: array[1, uint64]
b[0] = 1'u64 + 0x7FFF_FFFF_FFFF_FFFF'u64
b
const ok5: seq[uint64] = block:
@[0x8000_0000_0000_0000'u64]
when defined(arrbug):
const bad1: (uint64, array[1 .. 2, int]) = block:
var b: array[1 .. 2, int]
(0x8000_0000_0000_0000'u64, b)
when defined(seqbug):
const bad2: (seq[uint64], uint64) = block:
var x: seq[uint64]
x.add 0x8000_0000_0000_0000'u64
(x, 0'u64)
when defined(charbug):
const bad3: (char, uint64) = block:
('.', 1'u64 + 0x7FFF_FFFF_FFFF_FFFF'u64)Example Output
# bin/nim c -d:charbug what.nim
Hint: used config file '/Users/jfondren/nim/Nim/config/nim.cfg' [Conf]
Hint: used config file '/Users/jfondren/nim/Nim/config/config.nims' [Conf]
Hint: system [Processing]
Hint: widestrs [Processing]
Hint: io [Processing]
Hint: what [Processing]
what.nim(30, 5) Error: cannot convert -9223372036854775808 to uint64
Additional Information
Observed in latest devel and in 0.19.4