mirror of
https://github.com/nim-lang/Nim.git
synced 2026-02-14 15:23:27 +00:00
* Fixes #17849
* Update compiler/closureiters.nim
Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
(cherry picked from commit a6bd6c7ed8)
This commit is contained in:
@@ -604,6 +604,12 @@ proc lowerStmtListExprs(ctx: var Ctx, n: PNode, needsSplit: var bool): PNode =
|
||||
internalError(ctx.g.config, "lowerStmtListExpr(nkCaseStmt): " & $branch.kind)
|
||||
result.add(n)
|
||||
result.add(ctx.newEnvVarAccess(tmp))
|
||||
elif n[0].kind == nkStmtListExpr:
|
||||
result = newNodeI(nkStmtList, n.info)
|
||||
let (st, ex) = exprToStmtList(n[0])
|
||||
result.add(st)
|
||||
n[0] = ex
|
||||
result.add(n)
|
||||
|
||||
of nkCallKinds, nkChckRange, nkChckRangeF, nkChckRange64:
|
||||
var ns = false
|
||||
|
||||
@@ -483,5 +483,19 @@ block: # nnkChckRange
|
||||
|
||||
test(it, 1, 2, 3)
|
||||
|
||||
echo "ok"
|
||||
block: #17849 - yield in case subject
|
||||
template yieldInCase: int =
|
||||
yield 2
|
||||
3
|
||||
|
||||
iterator it(): int {.closure.} =
|
||||
yield 1
|
||||
case yieldInCase()
|
||||
of 1: checkpoint(11)
|
||||
of 3: checkpoint(13)
|
||||
else: checkpoint(14)
|
||||
yield 5
|
||||
|
||||
test(it, 1, 2, 13, 5)
|
||||
|
||||
echo "ok"
|
||||
|
||||
Reference in New Issue
Block a user