summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2018-06-06 17:31:24 +0200
committerGitHub <noreply@github.com>2018-06-06 17:31:24 +0200
commit42329e0a7002567c1b3cc61d1defa0dc794607bb (patch)
tree7db9a041e51164a1b82ceeec929202baf75e8832 /compiler
parente957d369b17cfb3532e2fe2aadfcde2bd3a0f11c (diff)
parent0ec2b33c50bf96e2b9f164fd8d44fe04fa76de52 (diff)
downloadNim-42329e0a7002567c1b3cc61d1defa0dc794607bb.tar.gz
Merge pull request #7971 from yglukhov/yield-in-dotexpr
Fixed yield in nkDotExpr. Fixes #7969.
Diffstat (limited to 'compiler')
-rw-r--r--compiler/closureiters.nim17
1 files changed, 15 insertions, 2 deletions
diff --git a/compiler/closureiters.nim b/compiler/closureiters.nim
index 75f0b92f6..3d86954c2 100644
--- a/compiler/closureiters.nim
+++ b/compiler/closureiters.nim
@@ -735,6 +735,19 @@ proc lowerStmtListExprs(ctx: var Ctx, n: PNode, needsSplit: var bool): PNode =
 
         n[0] = newSymNode(ctx.g.getSysSym(n[0].info, "true"))
         n[1] = newBody
+
+  of nkDotExpr:
+    var ns = false
+    n[0] = ctx.lowerStmtListExprs(n[0], ns)
+    if ns:
+      needsSplit = true
+      result = newNodeI(nkStmtListExpr, n.info)
+      result.typ = n.typ
+      let (st, ex) = exprToStmtList(n[0])
+      result.add(st)
+      n[0] = ex
+      result.add(n)
+
   else:
     for i in 0 ..< n.len:
       n[i] = ctx.lowerStmtListExprs(n[i], needsSplit)
@@ -843,8 +856,8 @@ proc transformClosureIteratorBody(ctx: var Ctx, n: PNode, gotoOut: PNode): PNode
       result[0] = ctx.transformClosureIteratorBody(result[0], gotoOut)
 
     of nkElifBranch, nkElifExpr, nkOfBranch:
-      result[1] = addGotoOut(result[1], gotoOut)
-      result[1] = ctx.transformClosureIteratorBody(result[1], gotoOut)
+      result[^1] = addGotoOut(result[^1], gotoOut)
+      result[^1] = ctx.transformClosureIteratorBody(result[^1], gotoOut)
 
     of nkIfStmt, nkCaseStmt:
       for i in 0 ..< n.len: