summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
authorflywind <43030857+xflywind@users.noreply.github.com>2021-02-15 07:22:46 -0600
committerGitHub <noreply@github.com>2021-02-15 14:22:46 +0100
commit339ebe958dad77caa04c50161a00288da8c3cab3 (patch)
treef3477c5e5d19ca4b8af12a3abe8d115a92f3c201 /compiler
parent55722fe04d67b443aeebc19bff46c3872b80f2fd (diff)
downloadNim-339ebe958dad77caa04c50161a00288da8c3cab3.tar.gz
JS: fix div uint64 no truncation (#16899)
Diffstat (limited to 'compiler')
-rw-r--r--compiler/jsgen.nim5
1 files changed, 4 insertions, 1 deletions
diff --git a/compiler/jsgen.nim b/compiler/jsgen.nim
index 04009250e..5d96907b5 100644
--- a/compiler/jsgen.nim
+++ b/compiler/jsgen.nim
@@ -671,7 +671,10 @@ proc arith(p: PProc, n: PNode, r: var TCompRes, op: TMagic) =
   of mAddU: binaryUintExpr(p, n, r, "+")
   of mSubU: binaryUintExpr(p, n, r, "-")
   of mMulU: binaryUintExpr(p, n, r, "*")
-  of mDivU: binaryUintExpr(p, n, r, "/")
+  of mDivU:
+    binaryUintExpr(p, n, r, "/")
+    if n[1].typ.skipTypes(abstractRange).size == 8:
+      r.res = "Math.trunc($1)" % [r.res]
   of mDivI:
     arithAux(p, n, r, op)
   of mModI: