Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 23 additions & 3 deletions compiler/ccgstmts.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions lib/system/excpt.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
Loading