diff options
-rw-r--r-- | compiler/closureiters.nim | 11 | ||||
-rw-r--r-- | lib/system/excpt.nim | 3 |
2 files changed, 6 insertions, 8 deletions
diff --git a/compiler/closureiters.nim b/compiler/closureiters.nim index c60ce96a2..c140b5464 100644 --- a/compiler/closureiters.nim +++ b/compiler/closureiters.nim @@ -90,9 +90,6 @@ # :unrollFinally = true # goto nearestFinally (or -1 if not exists) # -# Every finally block calls closureIterEndFinally() upon its successful -# completion. -# # Example: # # try: @@ -126,6 +123,7 @@ # if :curExc.isNil: # return :tmpResult # else: +# closureIterSetupExc(nil) # raise # state = -1 # Goto next state. In this case we just exit # break :stateLoop @@ -809,10 +807,11 @@ proc newEndFinallyNode(ctx: var Ctx, info: TLineInfo): PNode = let retStmt = newTree(nkReturnStmt, asgn) let branch = newTree(nkElifBranch, cmp, retStmt) - # The C++ backend requires `getCurrentException` here. - let raiseStmt = newTree(nkRaiseStmt, ctx.g.callCodegenProc("getCurrentException")) + let nullifyExc = newTree(nkCall, newSymNode(ctx.g.getCompilerProc("closureIterSetupExc")), nilnode) + nullifyExc.info = info + let raiseStmt = newTree(nkRaiseStmt, curExc) raiseStmt.info = info - let elseBranch = newTree(nkElse, raiseStmt) + let elseBranch = newTree(nkElse, newTree(nkStmtList, nullifyExc, raiseStmt)) let ifBody = newTree(nkIfStmt, branch, elseBranch) let elifBranch = newTree(nkElifBranch, ctx.newUnrollFinallyAccess(info), ifBody) diff --git a/lib/system/excpt.nim b/lib/system/excpt.nim index 767cf3d0d..0898ad0fd 100644 --- a/lib/system/excpt.nim +++ b/lib/system/excpt.nim @@ -136,8 +136,7 @@ proc popCurrentExceptionEx(id: uint) {.compilerRtl.} = prev.up = cur.up proc closureIterSetupExc(e: ref Exception) {.compilerproc, inline.} = - if not e.isNil: - currException = e + currException = e # some platforms have native support for stack traces: const |