fix #20272 range of uint64 shows signed upper bound (#20702)

This commit is contained in:
Bung 2022-11-01 12:58:32 +08:00 • committed by GitHub
commit 49e793e8c4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 1 deletions

View file

@ -450,7 +450,10 @@ proc mutateType(t: PType, iter: TTypeMutator, closure: RootRef): PType =
proc valueToString(a: PNode): string =
case a.kind
of nkCharLit..nkUInt64Lit: result = $a.intVal
of nkCharLit, nkUIntLit..nkUInt64Lit:
result = $cast[uint64](a.intVal)
of nkIntLit..nkInt64Lit:
result = $a.intVal
of nkFloatLit..nkFloat128Lit: result = $a.floatVal
of nkStrLit..nkTripleStrLit: result = a.strVal
else: result = "<invalid value>"

4
tests/misc/t6549.nim Normal file
View file

@ -0,0 +1,4 @@
const l = $(range[low(uint64) .. high(uint64)])
const r = "range 0..18446744073709551615(uint64)"
doAssert l == r