From 15e044416f53f3d87d53a74618b2fc4bb471eceb Mon Sep 17 00:00:00 2001 From: Araq Date: Mon, 5 Mar 2018 13:38:32 +0100 Subject: [PATCH] fixes #7291 --- lib/system/sysstr.nim | 2 +- tests/overload/tsystemcmp.nim | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/system/sysstr.nim b/lib/system/sysstr.nim index 31a59c0c0..5bf90c895 100644 --- a/lib/system/sysstr.nim +++ b/lib/system/sysstr.nim @@ -30,7 +30,7 @@ proc cmpStrings(a, b: NimString): int {.inline, compilerProc.} = if result == 0: result = a.len - b.len else: - result = 0 + result = a.len - b.len proc eqStrings(a, b: NimString): bool {.inline, compilerProc.} = if a == b: return true diff --git a/tests/overload/tsystemcmp.nim b/tests/overload/tsystemcmp.nim index 68cbf9fa7..aa761b759 100644 --- a/tests/overload/tsystemcmp.nim +++ b/tests/overload/tsystemcmp.nim @@ -1,12 +1,14 @@ discard """ cmd: r"nim c --hints:on $options --threads:on $file" + output: '''@["", "a", "ha", "hi", "ho", "huu"]''' """ import algorithm # bug #1657 -var modules = @["hi", "ho", "ha", "huu"] +var modules = @["hi", "ho", "", "a", "ha", "huu"] sort(modules, system.cmp) +echo modules type MyType = object