Skip to content

Commit

Permalink
fix nim-lang#20272 range of uint64 shows signed upper bound (nim-lang…
Browse files Browse the repository at this point in the history
  • Loading branch information
bung87 authored Nov 1, 2022
1 parent 2f6e06d commit 49e793e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 4 additions & 1 deletion compiler/types.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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>"
Expand Down
4 changes: 4 additions & 0 deletions tests/misc/t6549.nim
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

const l = $(range[low(uint64) .. high(uint64)])
const r = "range 0..18446744073709551615(uint64)"
doAssert l == r

0 comments on commit 49e793e

Please sign in to comment.