Fixed yield in dotExpr and nkOfBranch lowering. Closes #7969.

This commit is contained in:
Yuriy Glukhov
2018-06-06 16:17:24 +03:00
parent e957d369b1
commit 0ec2b33c50
2 changed files with 39 additions and 2 deletions

View File

@@ -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: