This commit is contained in:
Yuriy Glukhov 2018-09-04 09:18:11 +03:00 • committed by Andreas Rumpf
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 n[0] = ex
result.add(n) result.add(n)
of nkCast, nkHiddenStdConv, nkHiddenSubConv, nkConv: of nkCast, nkHiddenStdConv, nkHiddenSubConv, nkConv, nkObjDownConv:
var ns = false var ns = false
for i in 0 ..< n.len: for i in 0 ..< n.len:
n[i] = ctx.lowerStmtListExprs(n[i], ns) n[i] = ctx.lowerStmtListExprs(n[i], ns)
@ -687,9 +687,9 @@ proc lowerStmtListExprs(ctx: var Ctx, n: PNode, needsSplit: var bool): PNode =
needsSplit = true needsSplit = true
result = newNodeI(nkStmtListExpr, n.info) result = newNodeI(nkStmtListExpr, n.info)
result.typ = n.typ result.typ = n.typ
let (st, ex) = exprToStmtList(n[1]) let (st, ex) = exprToStmtList(n[^1])
result.add(st) result.add(st)
n[1] = ex n[^1] = ex
result.add(n) result.add(n)
of nkAsgn, nkFastAsgn: of nkAsgn, nkFastAsgn:

View file

@ -403,5 +403,18 @@ block: # yield in blockexpr
test(it, 1, 2, 3) 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" echo "ok"