Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #13186 #13188

Merged
merged 12 commits into from
Jan 19, 2020
6 changes: 4 additions & 2 deletions compiler/ccgstmts.nim
Original file line number Diff line number Diff line change
Expand Up @@ -1041,7 +1041,8 @@ proc genTryGoto(p: BProc; t: PNode; d: var TLoc) =
p.nestedTryStmts.add((fin, false, Natural lab))

p.flags.incl nimErrorFlagAccessed
linefmt(p, cpsStmts, "NI oldNimErr$1_ = *nimErr_; *nimErr_ = 0;;$n", [lab])
p.procSec(cpsLocals).add(ropecg(p.module, "NI oldNimErr$1_;$n", [lab]))
linefmt(p, cpsStmts, "oldNimErr$1_ = *nimErr_; *nimErr_ = 0;;$n", [lab])

expr(p, t[0], d)

Expand Down Expand Up @@ -1104,7 +1105,8 @@ proc genTryGoto(p: BProc; t: PNode; d: var TLoc) =
genStmts(p, t[i][0])
else:
# pretend we did handle the error for the safe execution of the 'finally' section:
linefmt(p, cpsStmts, "NI oldNimErrFin$1_ = *nimErr_; *nimErr_ = 0;$n", [lab])
p.procSec(cpsLocals).add(ropecg(p.module, "NI oldNimErrFin$1_;$n", [lab]))
linefmt(p, cpsStmts, "oldNimErrFin$1_ = *nimErr_; *nimErr_ = 0;$n", [lab])
genStmts(p, t[i][0])
# this is correct for all these cases:
# 1. finally is run during ordinary control flow
Expand Down