From fc9cccccd3773e05a7fb7f32272c1b55d5ad4241 Mon Sep 17 00:00:00 2001 From: Paul Tan Date: Wed, 23 Oct 2019 00:18:33 +0800 Subject: [PATCH] guards.nim:sameTree(): handle uint literals correctly (#12483) [backport] (cherry picked from commit ad3c10022afa3047a9bee73967c0d319541745b4) --- compiler/guards.nim | 2 +- tests/array/tarray.nim | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/compiler/guards.nim b/compiler/guards.nim index 52e0a1bdd9..8b7dc1d890 100644 --- a/compiler/guards.nim +++ b/compiler/guards.nim @@ -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 diff --git a/tests/array/tarray.nim b/tests/array/tarray.nim index 30244173a7..27288bab30 100644 --- a/tests/array/tarray.nim +++ b/tests/array/tarray.nim @@ -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