macros: Extend treeTraverse intVal range to nnkUInt64Lit (#21597)

* Extend intVal range to nnkUInt64Lit

Fixes #21593

* Properly cast intVal as unsigned

* Add testcase for #21593
This commit is contained in:
chmod222
2023-04-01 20:29:28 +02:00
committed by GitHub
parent a80f1a324f
commit 0c6f14af04
2 changed files with 15 additions and 0 deletions

View File

@@ -947,6 +947,8 @@ proc treeTraverse(n: NimNode; res: var string; level = 0; isLisp = false, indent
discard # same as nil node in this representation
of nnkCharLit .. nnkInt64Lit:
res.add(" " & $n.intVal)
of nnkUIntLit .. nnkUInt64Lit:
res.add(" " & $cast[uint64](n.intVal))
of nnkFloatLit .. nnkFloat64Lit:
res.add(" " & $n.floatVal)
of nnkStrLit .. nnkTripleStrLit, nnkCommentStmt, nnkIdent, nnkSym:

13
tests/macros/t21593.nim Normal file
View File

@@ -0,0 +1,13 @@
discard """
nimout: '''
StmtList
UIntLit 18446744073709551615
IntLit -1'''
"""
import macros
dumpTree:
0xFFFFFFFF_FFFFFFFF'u
0xFFFFFFFF_FFFFFFFF