diff options
author | flywind <43030857+xflywind@users.noreply.github.com> | 2020-12-27 03:13:57 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-27 10:13:57 +0100 |
commit | 3f9a2ebea5c0b02bcfcfe77ada36c33187bbf8bb (patch) | |
tree | f5c35fae0e17e8ce4688fa0ee0435a4d93077acf /lib | |
parent | 4cf605dcf6bdeacbb3f2ff8c7f17f5ff1afbe316 (diff) | |
download | Nim-3f9a2ebea5c0b02bcfcfe77ada36c33187bbf8bb.tar.gz |
fix nim js cmp fails at CT (#16473)
Diffstat (limited to 'lib')
-rw-r--r-- | lib/system.nim | 10 | ||||
-rw-r--r-- | lib/system/jssys.nim | 7 |
2 files changed, 8 insertions, 9 deletions
diff --git a/lib/system.nim b/lib/system.nim index 85ef15e08..fb008dc45 100644 --- a/lib/system.nim +++ b/lib/system.nim @@ -2394,14 +2394,8 @@ when notJSnotNims: """.} when defined(js): - when not defined(nimscript): - include "system/jssys" - include "system/reprjs" - else: - proc cmp(x, y: string): int = - if x == y: return 0 - if x < y: return -1 - return 1 + include "system/jssys" + include "system/reprjs" when defined(js) or defined(nimscript): proc addInt*(result: var string; x: int64) = diff --git a/lib/system/jssys.nim b/lib/system/jssys.nim index e2ceedc2c..5f18f01cb 100644 --- a/lib/system/jssys.nim +++ b/lib/system/jssys.nim @@ -340,7 +340,12 @@ proc cmpStrings(a, b: string): int {.asmNoStackFrame, compilerproc.} = """ proc cmp(x, y: string): int = - return cmpStrings(x, y) + when nimvm: + if x == y: result = 0 + elif x < y: result = -1 + else: result = 1 + else: + result = cmpStrings(x, y) proc eqStrings(a, b: string): bool {.asmNoStackFrame, compilerproc.} = asm """ |