summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2019-07-05 07:26:06 +0200
committerGitHub <noreply@github.com>2019-07-05 07:26:06 +0200
commit28c9c062a4f845b13d9dfd5ec8d23314675f7c10 (patch)
tree00324ea508177c2a4fbd37edf3c2d88b227fed83 /compiler
parentb64dd795b136248a60b8476d16bfe6e964b7fe18 (diff)
downloadNim-28c9c062a4f845b13d9dfd5ec8d23314675f7c10.tar.gz
fixes #11610 (#11659)
Diffstat (limited to 'compiler')
-rw-r--r--compiler/liftdestructors.nim2
-rw-r--r--compiler/semmagic.nim2
-rw-r--r--compiler/vmgen.nim9
3 files changed, 8 insertions, 5 deletions
diff --git a/compiler/liftdestructors.nim b/compiler/liftdestructors.nim
index 026a28893..e9be2ed18 100644
--- a/compiler/liftdestructors.nim
+++ b/compiler/liftdestructors.nim
@@ -292,7 +292,7 @@ proc forallElements(c: var TLiftCtx; t: PType; body, x, y: PNode) =
   let whileLoop = genWhileLoop(c, i, x)
   let elemType = t.lastSon
   fillBody(c, elemType, whileLoop.sons[1], x.at(i, elemType),
-                                              y.at(i, elemType))
+                                           y.at(i, elemType))
   addIncStmt(c, whileLoop.sons[1], i)
   body.add whileLoop
 
diff --git a/compiler/semmagic.nim b/compiler/semmagic.nim
index 47ade5191..1472cd2f3 100644
--- a/compiler/semmagic.nim
+++ b/compiler/semmagic.nim
@@ -355,6 +355,8 @@ proc semUnown(c: PContext; n: PNode): PNode =
 
   result = copyTree(n[1])
   result.typ = unownedType(c, result.typ)
+  # little hack for injectdestructors.nim (see bug #11350):
+  #result.sons[0].typ = nil
 
 proc magicsAfterOverloadResolution(c: PContext, n: PNode,
                                    flags: TExprFlags): PNode =
diff --git a/compiler/vmgen.nim b/compiler/vmgen.nim
index 9e1c4d602..e221929a2 100644
--- a/compiler/vmgen.nim
+++ b/compiler/vmgen.nim
@@ -501,7 +501,7 @@ proc genTry(c: PCtx; n: PNode; dest: var TDest) =
   c.gen(n.sons[0], dest)
   c.clearDest(n, dest)
   # Add a jump past the exception handling code
-  endings.add(c.xjmp(n, opcJmp, 0))
+  let jumpToFinally = c.xjmp(n, opcJmp, 0)
   # This signals where the body ends and where the exception handling begins
   c.patch(ehPos)
   for i in 1 ..< n.len:
@@ -525,6 +525,7 @@ proc genTry(c: PCtx; n: PNode; dest: var TDest) =
   let fin = lastSon(n)
   # we always generate an 'opcFinally' as that pops the safepoint
   # from the stack if no exception is raised in the body.
+  c.patch(jumpToFinally)
   c.gABx(fin, opcFinally, 0, 0)
   for endPos in endings: c.patch(endPos)
   if fin.kind == nkFinally:
@@ -2230,9 +2231,9 @@ proc genProc(c: PCtx; s: PSym): int =
     c.gABC(body, opcEof, eofInstr.regA)
     c.optimizeJumps(result)
     s.offset = c.prc.maxSlots
-    # if s.name.s == "fun1":
-    #   echo renderTree(body)
-    #   c.echoCode(result)
+    #if s.name.s == "main":
+    #  echo renderTree(body)
+    #  c.echoCode(result)
     c.prc = oldPrc
   else:
     c.prc.maxSlots = s.offset