guards.nim:sameTree(): handle uint literals correctly (#12483) [backport]

(cherry picked from commit ad3c10022a)
This commit is contained in:
Paul Tan
2019-10-23 00:18:33 +08:00
committed by narimiran
parent faf5ffd970
commit fc9cccccd3
2 changed files with 9 additions and 1 deletions

View File

@@ -436,7 +436,7 @@ proc sameTree*(a, b: PNode): bool =
if not result and a.sym.magic != mNone:
result = a.sym.magic == b.sym.magic or sameOpr(a.sym, b.sym)
of nkIdent: result = a.ident.id == b.ident.id
of nkCharLit..nkInt64Lit: result = a.intVal == b.intVal
of nkCharLit..nkUInt64Lit: result = a.intVal == b.intVal
of nkFloatLit..nkFloat64Lit: result = a.floatVal == b.floatVal
of nkStrLit..nkTripleStrLit: result = a.strVal == b.strVal
of nkType: result = a.typ == b.typ

View File

@@ -582,3 +582,11 @@ template append2*(args: varargs[string, myAppend]): string =
let foo = append2("1", "2", "3")
echo foo
block t12466:
# https://github.com/nim-lang/Nim/issues/12466
var a: array[288, uint16]
for i in 0'u16 ..< 144'u16:
a[0'u16 + i] = i
for i in 0'u16 ..< 8'u16:
a[0'u16 + i] = i