mirror of
https://github.com/nim-lang/Nim.git
synced 2026-02-15 07:43:26 +00:00
committed by
Andreas Rumpf
parent
e81fe6d32f
commit
1e6eca973d
@@ -712,6 +712,25 @@ proc lowerStmtListExprs(ctx: var Ctx, n: PNode, needsSplit: var bool): PNode =
|
||||
|
||||
result.add(n)
|
||||
|
||||
of nkBracketExpr:
|
||||
var lhsNeedsSplit = false
|
||||
var rhsNeedsSplit = false
|
||||
n[0] = ctx.lowerStmtListExprs(n[0], lhsNeedsSplit)
|
||||
n[1] = ctx.lowerStmtListExprs(n[1], rhsNeedsSplit)
|
||||
if lhsNeedsSplit or rhsNeedsSplit:
|
||||
needsSplit = true
|
||||
result = newNodeI(nkStmtListExpr, n.info)
|
||||
if lhsNeedsSplit:
|
||||
let (st, ex) = exprToStmtList(n[0])
|
||||
result.add(st)
|
||||
n[0] = ex
|
||||
|
||||
if rhsNeedsSplit:
|
||||
let (st, ex) = exprToStmtList(n[1])
|
||||
result.add(st)
|
||||
n[1] = ex
|
||||
result.add(n)
|
||||
|
||||
of nkWhileStmt:
|
||||
var ns = false
|
||||
|
||||
|
||||
@@ -416,5 +416,28 @@ block: #8851
|
||||
|
||||
test(it, 1)
|
||||
|
||||
block: # 8243
|
||||
iterator it(): int {.closure.} =
|
||||
template yieldAndSeq: seq[int] =
|
||||
yield 1
|
||||
@[123, 5, 123]
|
||||
|
||||
checkpoint(yieldAndSeq[1])
|
||||
|
||||
test(it, 1, 5)
|
||||
|
||||
block:
|
||||
iterator it(): int {.closure.} =
|
||||
template yieldAndSeq: seq[int] =
|
||||
yield 1
|
||||
@[123, 5, 123]
|
||||
|
||||
template yieldAndNum: int =
|
||||
yield 2
|
||||
1
|
||||
|
||||
checkpoint(yieldAndSeq[yieldAndNum])
|
||||
|
||||
test(it, 1, 2, 5)
|
||||
|
||||
echo "ok"
|
||||
|
||||
Reference in New Issue
Block a user