From 1deb9820f5473afc1469064488f4ed45a2aabb55 Mon Sep 17 00:00:00 2001 From: Araq Date: Tue, 19 Aug 2014 20:28:51 +0200 Subject: fixes #1420 --- compiler/types.nim | 2 +- tests/misc/tunsignedcmp.nim | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 tests/misc/tunsignedcmp.nim diff --git a/compiler/types.nim b/compiler/types.nim index 7559f4d2d..b25e3f697 100644 --- a/compiler/types.nim +++ b/compiler/types.nim @@ -99,7 +99,7 @@ proc isPureObject(typ: PType): bool = proc getOrdValue(n: PNode): BiggestInt = case n.kind - of nkCharLit..nkInt64Lit: result = n.intVal + of nkCharLit..nkUInt64Lit: result = n.intVal of nkNilLit: result = 0 of nkHiddenStdConv: result = getOrdValue(n.sons[1]) else: diff --git a/tests/misc/tunsignedcmp.nim b/tests/misc/tunsignedcmp.nim new file mode 100644 index 000000000..a66fbaae1 --- /dev/null +++ b/tests/misc/tunsignedcmp.nim @@ -0,0 +1,15 @@ +discard """ + output: '''true +true +true''' +""" + +# bug 1420 +import unsigned + +var x = 40'u32 +var y = 30'u32 +echo x > y # works + +echo((40'i32) > (30'i32)) +echo((40'u32) > (30'u32)) # Error: ordinal type expected -- cgit 1.4.1-2-gfad0