2 Informative error messages if the compiler generated destructor overrides a user-defined one.
6 fail_compilation/dtor_attributes.d(118): Error: `pure` function `dtor_attributes.test1` cannot call impure destructor `dtor_attributes.Strict.~this`
7 fail_compilation/dtor_attributes.d(113): generated `Strict.~this` is impure because of the following field's destructors:
8 fail_compilation/dtor_attributes.d(111): - HasDtor member
9 fail_compilation/dtor_attributes.d(103): impure `HasDtor.~this` is declared here
10 fail_compilation/dtor_attributes.d(118): Error: `@safe` function `dtor_attributes.test1` cannot call `@system` destructor `dtor_attributes.Strict.~this`
11 fail_compilation/dtor_attributes.d(113): `dtor_attributes.Strict.~this` is declared here
12 fail_compilation/dtor_attributes.d(113): generated `Strict.~this` is @system because of the following field's destructors:
13 fail_compilation/dtor_attributes.d(111): - HasDtor member
14 fail_compilation/dtor_attributes.d(103): @system `HasDtor.~this` is declared here
15 fail_compilation/dtor_attributes.d(118): Error: `@nogc` function `dtor_attributes.test1` cannot call non-@nogc destructor `dtor_attributes.Strict.~this`
16 fail_compilation/dtor_attributes.d(113): generated `Strict.~this` is non-@nogc because of the following field's destructors:
17 fail_compilation/dtor_attributes.d(111): - HasDtor member
18 fail_compilation/dtor_attributes.d(103): non-@nogc `HasDtor.~this` is declared here
19 fail_compilation/dtor_attributes.d(118): Error: destructor `dtor_attributes.Strict.~this` is not `nothrow`
20 fail_compilation/dtor_attributes.d(113): generated `Strict.~this` is not nothrow because of the following field's destructors:
21 fail_compilation/dtor_attributes.d(111): - HasDtor member
22 fail_compilation/dtor_attributes.d(103): not nothrow `HasDtor.~this` is declared here
23 fail_compilation/dtor_attributes.d(116): Error: function `dtor_attributes.test1` may throw but is marked as `nothrow`
33 // The user-defined dtor is overridden by a generated dtor calling both
40 ~this() pure nothrow @nogc @safe {}
43 void test1() pure nothrow @nogc @safe
49 Works for clases as well.
53 fail_compilation/dtor_attributes.d(209): Error: `pure` function `dtor_attributes.test2` cannot call impure destructor `dtor_attributes.StrictClass.~this`
54 fail_compilation/dtor_attributes.d(204): generated `StrictClass.~this` is impure because of the following field's destructors:
55 fail_compilation/dtor_attributes.d(203): - HasDtor member
56 fail_compilation/dtor_attributes.d(103): impure `HasDtor.~this` is declared here
69 scope instance
= new StrictClass();
73 Ignores members whose destructors are not called.
77 fail_compilation/dtor_attributes.d(321): Error: `pure` function `dtor_attributes.test3` cannot call impure destructor `dtor_attributes.StrictStructRef.~this`
78 fail_compilation/dtor_attributes.d(316): generated `StrictStructRef.~this` is impure because of the following field's destructors:
79 fail_compilation/dtor_attributes.d(310): - HasDtor structMember
80 fail_compilation/dtor_attributes.d(103): impure `HasDtor.~this` is declared here
92 struct StrictStructRef
95 HasDtorClass classMember
;
105 StrictStructRef structInstance
;
109 Types from nested types work as well.
113 fail_compilation/dtor_attributes.d(411): Error: `pure` function `dtor_attributes.test4` cannot call impure destructor `dtor_attributes.StrictNested.~this`
114 fail_compilation/dtor_attributes.d(406): generated `StrictNested.~this` is impure because of the following field's destructors:
115 fail_compilation/dtor_attributes.d(403): - HasDtor[4] arrayMember
116 fail_compilation/dtor_attributes.d(103): impure `HasDtor.~this` is declared here
123 HasDtor
[4] arrayMember
;
124 HasDtorClass
[4] classMember
;
131 StrictNested structInstance
;
135 Ignores member destructors when the user-defined one is permissive enough (e.g. both impure)
139 fail_compilation/dtor_attributes.d(509): Error: `pure` function `dtor_attributes.test5` cannot call impure destructor `dtor_attributes.Permissive.~this`
146 HasDtor
[4] arrayMember
;
152 Permissive structInstance
;
156 Works with destructors generated through multiple layers
160 fail_compilation/dtor_attributes.d(618): Error: `pure` function `dtor_attributes.test6` cannot call impure destructor `dtor_attributes.HasNestedDtor3.~this`
161 fail_compilation/dtor_attributes.d(611): generated `HasNestedDtor3.~this` is impure because of the following field's destructors:
162 fail_compilation/dtor_attributes.d(613): - HasNestedDtor2 member3
163 fail_compilation/dtor_attributes.d(606): generated `HasNestedDtor2.~this` is impure because of the following field's destructors:
164 fail_compilation/dtor_attributes.d(608): - HasNestedDtor1 member2
165 fail_compilation/dtor_attributes.d(601): generated `HasNestedDtor1.~this` is impure because of the following field's destructors:
166 fail_compilation/dtor_attributes.d(603): - HasDtor member1
167 fail_compilation/dtor_attributes.d(103): impure `HasDtor.~this` is declared here
172 struct HasNestedDtor1
177 struct HasNestedDtor2
179 HasNestedDtor1 member2
;
182 struct HasNestedDtor3
184 HasNestedDtor2 member3
;
189 HasNestedDtor3 instance
;