fixes #25903 and #25904; add closure iterators with error handling (#25905)

fixes #25903
fixes #25904

`nkExceptBranch` can have variable structure depending on the exception
types and it should handle the last node of the `nkExceptBranch`

(cherry picked from commit 0f751695e4)
This commit is contained in:
ringabout
2026-06-13 13:03:28 +08:00
committed by narimiran
parent 48a5db9ecc
commit 5fc6a3881a
2 changed files with 18 additions and 4 deletions

View File

@@ -593,10 +593,7 @@ proc lowerStmtListExprs(ctx: var Ctx, n: PNode, needsSplit: var bool): PNode =
let branch = n[i]
case branch.kind
of nkExceptBranch:
if branch[0].kind == nkType:
branch[1] = ctx.convertExprBodyToAsgn(branch[1], tmp)
else:
branch[0] = ctx.convertExprBodyToAsgn(branch[0], tmp)
branch[^1] = ctx.convertExprBodyToAsgn(branch[^1], tmp)
of nkFinally:
discard
else: