This commit is contained in:
Yuriy Glukhov
2018-09-04 09:18:11 +03:00
committed by Andreas Rumpf
parent e789acb59b
commit d2eea9e1c9
2 changed files with 16 additions and 3 deletions

View File

@@ -678,7 +678,7 @@ proc lowerStmtListExprs(ctx: var Ctx, n: PNode, needsSplit: var bool): PNode =
n[0] = ex
result.add(n)
of nkCast, nkHiddenStdConv, nkHiddenSubConv, nkConv:
of nkCast, nkHiddenStdConv, nkHiddenSubConv, nkConv, nkObjDownConv:
var ns = false
for i in 0 ..< n.len:
n[i] = ctx.lowerStmtListExprs(n[i], ns)
@@ -687,9 +687,9 @@ proc lowerStmtListExprs(ctx: var Ctx, n: PNode, needsSplit: var bool): PNode =
needsSplit = true
result = newNodeI(nkStmtListExpr, n.info)
result.typ = n.typ
let (st, ex) = exprToStmtList(n[1])
let (st, ex) = exprToStmtList(n[^1])
result.add(st)
n[1] = ex
n[^1] = ex
result.add(n)
of nkAsgn, nkFastAsgn:

View File

@@ -403,5 +403,18 @@ block: # yield in blockexpr
test(it, 1, 2, 3)
block: #8851
type
Foo = ref object of RootObj
template someFoo(): Foo =
var f: Foo
yield 1
f
iterator it(): int {.closure.} =
var o: RootRef
o = someFoo()
test(it, 1)
echo "ok"