From 0fa82763feff2b7af67af19a86fb1e1dafe5f3bc Mon Sep 17 00:00:00 2001 From: Joseph Turner Date: Thu, 9 Apr 2015 03:59:08 +0100 Subject: [PATCH 1/2] Fixes #1986 when calling sameConstant on uint The problem was saveConstant only checked the range `nkCharLit..nkInt64Lit`, but not up to UInt. This lead to the sonsLen method being called, where sons was never declared. This commit changes it to `nkCharLit..nkUint64Lit`, to match the case statements in the type definition of TNode, in ast.nim. --- compiler/vmgen.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/vmgen.nim b/compiler/vmgen.nim index 3178bee60c..c3013852d1 100644 --- a/compiler/vmgen.nim +++ b/compiler/vmgen.nim @@ -368,7 +368,7 @@ proc sameConstant*(a, b: PNode): bool = case a.kind of nkSym: result = 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, nkNilLit: result = a.typ == b.typ From e336da9dd98ed4befa2b46771b3f40888676e4db Mon Sep 17 00:00:00 2001 From: Joseph Turner Date: Thu, 9 Apr 2015 05:00:11 +0100 Subject: [PATCH 2/2] Adds test file, for bug #1986 --- tests/tuples/tuint_tuple.nim | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 tests/tuples/tuint_tuple.nim diff --git a/tests/tuples/tuint_tuple.nim b/tests/tuples/tuint_tuple.nim new file mode 100644 index 0000000000..24bcead5e6 --- /dev/null +++ b/tests/tuples/tuint_tuple.nim @@ -0,0 +1,10 @@ +# bug #1986 found by gdmoore + +proc test(): int64 = + return 0xdeadbeef.int64 + +const items = [ + (var1: test(), var2: 100'u32), + (var1: test(), var2: 192'u32) +] +