import std.stdio; void callDelegate(void delegate() cb) { cb(); } void writeEx(Throwable o) { writefln("%s", o); } void works1() { Throwable o2; try { throw(new Exception("This is an error")); } catch (Throwable o) { o2 = o; callDelegate({ writefln("%s", o2); }); } } void works2() { try { throw(new Exception("This is an error")); } catch (Throwable o) { writeEx(o); } } void do_not_work() { try { throw(new Exception("This is an error")); } catch (Throwable o) { callDelegate({ writefln("%s", o); }); } } int main(string[] args) { works1(); works2(); do_not_work(); return 0; }
Confirmed with 2.059
I just compiled and ran the code with the latest master. It successfully compiles, runs and exits gracefully. It seems like this has been fixed.