diff options
author | Paul Tan <pyokagan@gmail.com> | 2019-10-23 00:18:33 +0800 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2019-10-22 18:18:33 +0200 |
commit | ad3c10022afa3047a9bee73967c0d319541745b4 (patch) | |
tree | b99c08692385843dab21f342a7ac70d78efdb41b | |
parent | 2ccd1c34284f08ba8e4c7b5b4986de8899f60354 (diff) | |
download | Nim-ad3c10022afa3047a9bee73967c0d319541745b4.tar.gz |
guards.nim:sameTree(): handle uint literals correctly (#12483) [backport]
-rw-r--r-- | compiler/guards.nim | 2 | ||||
-rw-r--r-- | tests/array/tarray.nim | 8 |
2 files changed, 9 insertions, 1 deletions
diff --git a/compiler/guards.nim b/compiler/guards.nim index 52e0a1bdd..8b7dc1d89 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 30244173a..27288bab3 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 |