diff --git a/compiler/ccgstmts.nim b/compiler/ccgstmts.nim index 3aedca9a965d7..2fc92741fbf72 100644 --- a/compiler/ccgstmts.nim +++ b/compiler/ccgstmts.nim @@ -135,7 +135,7 @@ proc genVarTuple(p: BProc, n: PNode) = initLocalVar(p, v, immediateAsgn=isAssignedImmediately(p.config, n[^1])) var field = initLoc(locExpr, vn, tup.storage) let rtup = rdLoc(tup) - let fieldName = + let fieldName = if t.kind == tyTuple: "Field" & $i else: @@ -858,8 +858,28 @@ proc genRaiseStmt(p: BProc, t: PNode) = of excCpp: blockLeaveActions(p, howManyTrys = 0, howManyExcepts = p.inExceptBlockLen) of excGoto: - blockLeaveActions(p, howManyTrys = 0, - howManyExcepts = (if p.nestedTryStmts.len > 0 and p.nestedTryStmts[^1].inExcept: 1 else: 0)) + #[ + There is a difference between: + + try: + something() + except: + # bug #25037 + try: + let tmp = someValue() + raise E(tmp) + finally: + destroy(tmp) + + And: + + try: + something() + except: + raise E + ]# + if noSafePoints notin p.flags: + p.s(cpsStmts).addCallStmt(cgsymValue(p.module, "popAllButOneCurrentExceptions")) else: discard genLineDir(p, t) diff --git a/lib/system/excpt.nim b/lib/system/excpt.nim index 5563b1adf0737..f8d93145d77bf 100644 --- a/lib/system/excpt.nim +++ b/lib/system/excpt.nim @@ -158,6 +158,10 @@ proc popCurrentException {.compilerRtl, inl.} = currException = currException.up #showErrorMessage2 "B" +proc popAllButOneCurrentExceptions {.compilerRtl, inl.} = + while currException != nil and currException.up != nil: + currException = currException.up + proc popCurrentExceptionEx(id: uint) {.compilerRtl.} = discard "only for bootstrapping compatbility"