https://issues.dlang.org/show_bug.cgi?id=14903
--- Comment #7 from David Nadlinger <c...@klickverbot.at> --- This patch should fix the issue where no dtors are run at all: ————— --- a/dmd2/expression.c +++ b/dmd2/expression.c @@ -1889,10 +1889,7 @@ bool functionParameters(Loc loc, Scope *sc, TypeFunction *tf, } } } - if (anythrow && i == lastthrow) - { - appendToPrefix = false; - } + if (appendToPrefix) // don't need to add to prefix until there's something to destruct { Identifier *idtmp = Identifier::generateId("__pfx"); @@ -1901,8 +1898,14 @@ bool functionParameters(Loc loc, Scope *sc, TypeFunction *tf, tmp->semantic(sc); /* Modify the destructor so it only runs if gate==false + * We immediately set the gate to true after the last throwing argument + * has been constructed, so we can directly fold away the check. */ - if (tmp->edtor) + if (i == lastthrow) + { + tmp->edtor = NULL; + } + else if(tmp->edtor) { Expression *e = tmp->edtor; e = new OrOrExp(e->loc, new VarExp(e->loc, gate), e); // (gate || destructor) ————— Previously, the gate was set to true before the last throwing argument, which is obviously wrong if it indeed throws. Don't have time to turn this into a proper DMD PR myself at the moment, though. --