On Sunday, 4 July 2021 at 10:07:08 UTC, jfondren wrote:

Not cleaning up after an Error is thrown is allowed by the D spec. This enhancement allows much better code to be generated for `nothrow` code when `scope` is used. It will also not unwind declarations with destructors in `nothrow` code when Errors are thrown.

I read this initially as "it is a bug for scope(exit) to ever run after an Error is thrown", but it's an optimization for nothrow code, which fits what you're seeing.

So it's might not a bug but not well documented.

```scope(...)``` still acts as ```try... catch(Throwable)... finally``` as logic people would expect although not written in stone anywhere.

Code within that blocks that are not seen by the compiler as 'nothrow' will be executed. But the compiler may silently mark code as 'nothrow' if possible and then this "feature" gets enabled and cleanup will be discarded.


Reply via email to