Closed
Description
Description
this runs fine
block :
let test_u64 : uint64 = 0xFFFFFFFFFFFF03.uint64
let test_u8 : uint8 = test_u64.uint8
echo test_u8
and shows the value of the lowest byte : 3
but the same code at compile-time
static :
let test_u64 : uint64 = 0xFFFFFFFFFFFF03.uint64
let test_u8 : uint8 = test_u64.uint8
echo test_u8
breaks with
Error: illegal conversion from '72057594037927683' to '[0..255]'
in the line
let test_u8 : uint8 = test_u64.uint8
Expected Output
to be the same as at execution-time :
3 , the value of the lowest byte
Possible Solution
in the nimvm implementation adding
before the conversion
and 0xFF
to extract the lowest byte and have it in range [0..255] ,
identical to the behaviour at execution-time .
Nim Version
nim -v
Nim Compiler Version 2.1.1 [Windows: amd64]
Compiled at 2023-12-26
Additional Information
compiled with the cmdLine
nim compile test.nim
on the gcc version :
winlibs-x86_64-posix-seh-gcc-13.2.0-mingw-w64ucrt-11.0.1-r3
Metadata
Metadata
Assignees
Labels
No labels