dmd/changelog/dmd.deprecation-dtor-fields.dd
2025-02-14 08:23:16 +08:00

32 lines
661 B
Text

An error is now given for constructors when a field's destructor has stricter attributes
```
struct HasDtor
{
~this() {}
}
struct Pure
{
HasDtor member;
this(int) pure {} // Error: `this` has stricter attributes than its destructor (`pure`)
}
struct Nothrow
{
HasDtor member;
this(int) nothrow {} // Error: `this` has stricter attributes than its destructor (`nothrow`)
}
struct NoGC
{
HasDtor member;
this(int) @nogc {} // Error: `this` has stricter attributes than its destructor (`@nogc`)
}
struct Safe
{
HasDtor member;
this(int) @safe {} // Error: `this` has stricter attributes than its destructor (`@safe`)
}
```