summary refs log tree commit diff stats
path: root/compiler/vmgen.nim
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2019-10-20 22:37:31 +0200
committerGitHub <noreply@github.com>2019-10-20 22:37:31 +0200
commit38b3590e40b7267195c65168e6ff064775de4339 (patch)
tree470130ede0af04c3209a2bd33531427759670acd /compiler/vmgen.nim
parentec20fd35447fea2a5da8538260397cea24051db5 (diff)
downloadNim-38b3590e40b7267195c65168e6ff064775de4339.tar.gz
fixes #12310 [backport] (#12470)
Diffstat (limited to 'compiler/vmgen.nim')
-rw-r--r--compiler/vmgen.nim8
1 files changed, 6 insertions, 2 deletions
diff --git a/compiler/vmgen.nim b/compiler/vmgen.nim
index 09e02f818..b528ff7be 100644
--- a/compiler/vmgen.nim
+++ b/compiler/vmgen.nim
@@ -948,9 +948,13 @@ proc genMagic(c: PCtx; n: PNode; dest: var TDest; m: TMagic) =
     c.genAddSubInt(n, dest, opcAddInt)
   of mInc, mDec:
     unused(c, n, dest)
-    let opc = if m == mInc: opcAddInt else: opcSubInt
+    let isUnsigned = n.sons[1].typ.skipTypes(abstractVarRange).kind in {tyUInt..tyUInt64}
+    let opc = if not isUnsigned:
+                if m == mInc: opcAddInt else: opcSubInt
+              else:
+                if m == mInc: opcAddu else: opcSubu
     let d = c.genx(n.sons[1])
-    if n.sons[2].isInt8Lit:
+    if n.sons[2].isInt8Lit and not isUnsigned:
       c.gABI(n, succ(opc), d, d, n.sons[2].intVal)
     else:
       let tmp = c.genx(n.sons[2])