Fixed compilation of void closureiters with try stmt (#20138) [backport]
This commit is contained in:
parent
02cbd7dc53
commit
0d734d7966
2 changed files with 15 additions and 4 deletions
|
|
@ -825,10 +825,13 @@ proc newEndFinallyNode(ctx: var Ctx, info: TLineInfo): PNode =
|
||||||
let retStmt =
|
let retStmt =
|
||||||
if ctx.nearestFinally == 0:
|
if ctx.nearestFinally == 0:
|
||||||
# last finally, we can return
|
# last finally, we can return
|
||||||
let asgn = newTree(nkFastAsgn,
|
let retValue = if ctx.fn.typ[0].isNil:
|
||||||
newSymNode(getClosureIterResult(ctx.g, ctx.fn, ctx.idgen), info),
|
ctx.g.emptyNode
|
||||||
ctx.newTmpResultAccess())
|
else:
|
||||||
newTree(nkReturnStmt, asgn)
|
newTree(nkFastAsgn,
|
||||||
|
newSymNode(getClosureIterResult(ctx.g, ctx.fn, ctx.idgen), info),
|
||||||
|
ctx.newTmpResultAccess())
|
||||||
|
newTree(nkReturnStmt, retValue)
|
||||||
else:
|
else:
|
||||||
# bubble up to next finally
|
# bubble up to next finally
|
||||||
newTree(nkGotoState, ctx.g.newIntLit(info, ctx.nearestFinally))
|
newTree(nkGotoState, ctx.g.newIntLit(info, ctx.nearestFinally))
|
||||||
|
|
|
||||||
|
|
@ -495,3 +495,11 @@ block: #17849 - yield in case subject
|
||||||
yield 5
|
yield 5
|
||||||
|
|
||||||
test(it, 1, 2, 13, 5)
|
test(it, 1, 2, 13, 5)
|
||||||
|
|
||||||
|
block: # void iterator
|
||||||
|
iterator it() {.closure.} =
|
||||||
|
try:
|
||||||
|
yield
|
||||||
|
except:
|
||||||
|
discard
|
||||||
|
var a = it
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue