From 5d6053173a0db2b4d0dd1c334c41075fe8d9850e Mon Sep 17 00:00:00 2001 From: Araq Date: Sun, 6 Apr 2014 19:53:24 +0200 Subject: [PATCH] fixes #297 --- tests/typerel/texplicitcmp.nim | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 tests/typerel/texplicitcmp.nim diff --git a/tests/typerel/texplicitcmp.nim b/tests/typerel/texplicitcmp.nim new file mode 100644 index 0000000000..8aec9885ab --- /dev/null +++ b/tests/typerel/texplicitcmp.nim @@ -0,0 +1,32 @@ +discard """ + output: '''[1 2 3 ] +[1 2 3 ] +[1 2 3 ]''' +""" + +# bug #297 + +import json, tables, algorithm + +proc outp(a: openarray[int]) = + stdout.write "[" + for i in a: stdout.write($i & " ") + stdout.write "]\n" + +proc works() = + var f = @[3, 2, 1] + sort(f, system.cmp[int]) + outp(f) + +proc weird(json_params: TTable) = + var f = @[3, 2, 1] + # The following line doesn't compile: type mismatch. Why? + sort(f, system.cmp[int]) + outp(f) + +when isMainModule: + var t = @[3, 2, 1] + sort(t, system.cmp[int]) + outp(t) + works() + weird(initTable[string, TJsonNode]())