@@ -1144,10 +1144,10 @@ void main()
1144
1144
$(P The postblits `__fieldPostblit` and `__aggrPostblit`
1145
1145
are generated without any implicit qualifiers and are not considered
1146
1146
struct members. This leads to the situation where qualifying an
1147
- entire struct declaration does not have any impact on the above
1148
- mentioned postblits. However, since `__xpostblit` is a member of
1149
- the struct and an alias of one of the other postblits, the qualifiers
1150
- applied to the struct will affect the aliased postblit: )
1147
+ entire struct declaration with `const` or `immutable` does not have
1148
+ any impact on the above- mentioned postblits. However, since `__xpostblit`
1149
+ is a member of the struct and an alias of one of the other postblits,
1150
+ the qualifiers applied to the struct will affect the aliased postblit. )
1151
1151
1152
1152
$(SPEC_RUNNABLE_EXAMPLE_FAIL
1153
1153
---
@@ -1186,32 +1186,40 @@ immutable struct C2
1186
1186
{
1187
1187
S a;
1188
1188
}
1189
+ ---
1190
+ )
1189
1191
1190
- // Similar to B
1191
- shared struct D
1192
+ $(P In the above situations the errors do not contain line numbers because
1193
+ the errors are regarding generated code.
1194
+ )
1195
+
1196
+ $(P Qualifying an entire struct as `shared` correctly propagates the attribute
1197
+ to the generated postblits:)
1198
+
1199
+ $(SPEC_RUNNABLE_EXAMPLE_COMPILE
1200
+ ---
1201
+ shared struct A
1192
1202
{
1193
- // error: non-shared method S.__postblit is not callable using a shared object
1194
- // error: non-shared method D.__fieldPostblit is not callable using a shared object
1195
- S a;
1196
1203
this(this)
1197
- { }
1204
+ {
1205
+ import std.stdio : writeln;
1206
+ writeln("the shared postblit was called");
1207
+ }
1198
1208
}
1199
1209
1200
- // Unlike B2, this example also does not work due to additional restrictions on shared.
1201
- shared struct D2
1210
+ struct B
1202
1211
{
1203
- // error: non-shared method S.__postblit is not callable using a shared object
1204
- S a;
1212
+ A a;
1213
+ }
1214
+
1215
+ void main()
1216
+ {
1217
+ shared B b1;
1218
+ auto b2 = b1;
1205
1219
}
1206
1220
---
1207
1221
)
1208
1222
1209
- $(P In the above situations the errors do not contain line numbers because
1210
- the errors are regarding generated code. In the case of the `shared` struct,
1211
- the first error message can be suppressed by qualifying the postblit of `S`
1212
- with `shared`.
1213
- )
1214
-
1215
1223
$(P Unions may not have fields that have postblits.)
1216
1224
1217
1225
$(H2 $(LEGACY_LNAME2 StructDestructor, struct-destructor, Struct Destructors))
0 commit comments