I hate class destructors with a burning passion

FeepingCreature feepingcreature at gmail.com
Thu Jun 10 12:56:09 UTC 2021


On Thursday, 10 June 2021 at 12:49:19 UTC, FeepingCreature wrote:
> Note that -preview=inclusiveincontracts changes the semantics 
> so that AssertError is, while still caught, never *swallowed* 
> but at most converted into another Error. In other words, if 
> the parent in-condition throws, the child in-condition will 
> always throw as well.
>
> For discussion of this feature, see 
> https://github.com/dlang/dmd/pull/11465 .
>

Sorry, let me correct that and explain a bit more.

The semantics change of "inclusive in-contracts" is that the 
in-contract of the child has to include the in-contract of the 
parent in the course of expanding it. In other words, you can't 
override `foo(int i) in (i == 2)` with `foo(int i) in (i == 3)`, 
but only with `foo(int i) in (i == 2 || i == 3)`. This is 
validated by first checking the child contract, then if it fails, 
recursively checking that the parent also failed. In other words, 
the child's error is caught, but the handler then either throws 
the parent's error or a `LogicError`.

So with this change, `assert` can violate `@nogc` as it wants, 
because the program cannot get out of throwing an `Error` one way 
or another.


More information about the Digitalmars-d mailing list