Bug 21213 – preview=dtorfields with strict attributes in base class constructor
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2020-08-31T15:06:31Z
Last change time
2020-09-03T23:02:18Z
Keywords
pull
Assigned to
No Owner
Creator
moonlightsentinel
Comments
Comment #0 by moonlightsentinel — 2020-08-31T15:06:31Z
The following test case doesn't compile with `-preview=dtorfields`:
===================================================
class Parent
{
this() nothrow pure @nogc @safe {}
}
class Child : Parent
{
S s;
// this() {} // Uncomment this to make the test pass
}
struct S
{
~this() {}
}
===================================================
onlineapp.d(6): Error: `pure` constructor `onlineapp.Child.this` cannot call impure destructor `onlineapp.Child.~this`
onlineapp.d(6): Error: `@safe` constructor `onlineapp.Child.this` cannot call `@system` destructor `onlineapp.Child.~this`
onlineapp.d(6): `onlineapp.Child.~this` is declared here
onlineapp.d(6): Error: `@nogc` constructor `onlineapp.Child.this` cannot call non-@nogc destructor `onlineapp.Child.~this`
Comment #1 by dlang-bot — 2020-09-01T16:05:38Z
@MoonlightSentinel updated dlang/dmd pull request #11659 " Fix Issue 21213 - preview=dtorfields with strict attributes... " fixing this issue:
- Fix Issue 21213 - preview=dtorfields with strict attributes...
... in base class constructor - by infer attributes for generated
subclass constructors.
Simply copying the attributes from the base class ctor doesn't work if
other lowerings extend the generated function body.
This is e.g. problematic for `-preview=dtorfields` which adds a call
to the destructor which is often less qualified than the constructor.
https://github.com/dlang/dmd/pull/11659
Comment #2 by dlang-bot — 2020-09-03T23:02:18Z
dlang/dmd pull request #11659 " Fix Issue 21213 - preview=dtorfields with strict attributes... " was merged into master:
- fd9adfc77fee6e3f930e20e26063a58b847daf66 by MoonlightSentinel:
Fix Issue 21213 - preview=dtorfields with strict attributes...
... in base class constructor - by infer attributes for generated
subclass constructors.
Simply copying the attributes from the base class ctor doesn't work if
other lowerings extend the generated function body.
This is e.g. problematic for `-preview=dtorfields` which adds a call
to the destructor which is often less qualified than the constructor.
https://github.com/dlang/dmd/pull/11659