On 10/16/20 6:12 AM, tchaloupka wrote:

> struct Foo {
>      Bar bar;
>      bool err;
>
>      ~this() {
>          // scope(failure) destroy(bar); // < this fixes the Bar
> destructor call
>          enforce(!err, "Test err");

Well, that check means "cannot continue", which means the compiler stops executing the destruction code because it can't. (It would a serious bug if it continued execution in a state that the program knows to be invalid.)

>      }

Conceptually, bar's destructor is called on that closing brace but we decided to abort mission earlier. Your calling destroy(bar) may or may not be wrong in case of 'err'. Only you know at that point.

> Is this behavior expected?

Yes.

Ali

Reply via email to