On Thursday, 20 September 2018 at 10:48:35 UTC, Atila Neves wrote:
What's the fix? Have the compiler insert a call to the exception's destructor at the end of the `catch(scope Exception)` block.
If I understood you correctly then we have same idea. If exception is not handled or re thrown then scope "exits" trough scope(failure) in which case no deallocation should be performed and only if scope "exits" trough scope(success), meaning exception/s were handled, destructors need to be called.
To make exceptions nogc we need destructors that are aware of how scope was exited like:
~ this(exit) ( ) {} ~ this(success) ( ) {} ~ this(failure) ( ) {} With this its easy to make all exceptions nogc