From d5be91799403c9ba9ee526d9760b07f232f91f2d Mon Sep 17 00:00:00 2001 From: Bung Date: Tue, 1 Nov 2022 12:58:32 +0800 Subject: [PATCH] fix #20272 range of uint64 shows signed upper bound (#20702) (cherry picked from commit 49e793e8c4b42a5bc08bc6ed27123389c3bdc353) --- compiler/types.nim | 5 ++++- tests/misc/t6549.nim | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 tests/misc/t6549.nim diff --git a/compiler/types.nim b/compiler/types.nim index 6217310607..7da1efa1ef 100644 --- a/compiler/types.nim +++ b/compiler/types.nim @@ -448,7 +448,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 = "" diff --git a/tests/misc/t6549.nim b/tests/misc/t6549.nim new file mode 100644 index 0000000000..1d7393318d --- /dev/null +++ b/tests/misc/t6549.nim @@ -0,0 +1,4 @@ + +const l = $(range[low(uint64) .. high(uint64)]) +const r = "range 0..18446744073709551615(uint64)" +doAssert l == r