diff --git a/compiler/ccgstmts.nim b/compiler/ccgstmts.nim index 5322723743..c56340e00f 100644 --- a/compiler/ccgstmts.nim +++ b/compiler/ccgstmts.nim @@ -1218,6 +1218,10 @@ proc genTryGoto(p: BProc; t: PNode; d: var TLoc) = p.nestedTryStmts.add((fin, false, Natural lab)) p.flags.incl nimErrorFlagAccessed + + if not isEmptyType(t.typ) and d.k == locNone: + getTemp(p, t.typ, d) + expr(p, t[0], d) if 1 < t.len and t[1].kind == nkExceptBranch: diff --git a/tests/destructor/tgotoexceptions8.nim b/tests/destructor/tgotoexceptions8.nim index e968cdce2d..8ed2ed0bad 100644 --- a/tests/destructor/tgotoexceptions8.nim +++ b/tests/destructor/tgotoexceptions8.nim @@ -8,7 +8,8 @@ outer finally msg1 msg2 finally2 -finally1''' +finally1 +true''' cmd: "nim c --gc:arc $file" """ @@ -67,3 +68,9 @@ when true: echo "finally1" nested_finally() + +# bug #14925 +proc test(b: bool) = + echo b + +test(try: true except: false)