You can already do it with a slight change, and it's not so painful, at least in simple functions: int foo(bool b) { auto result = 2; scope(exit) writeln(result); if (b) { result = 1; } return result; }