@@ -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,39 @@ immutable struct C2
1186
1186
{
1187
1187
S a;
1188
1188
}
1189
+ ---
1189
1190
1190
- // Similar to B
1191
- shared struct D
1191
+ $(P In the above situations the errors do not contain line numbers because
1192
+ the errors are regarding generated code.
1193
+ )
1194
+
1195
+ $(P Qualifing an entire struct as `shared` correctly propagates the attribute
1196
+ to the generated postblits:)
1197
+
1198
+ $(SPEC_RUNNABLE_EXAMPLE_COMPILE
1199
+ ---
1200
+ shared struct A
1192
1201
{
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
1202
this(this)
1197
- { }
1203
+ {
1204
+ import std.stdio : writeln;
1205
+ writeln("the shared postblit was called");
1206
+ }
1198
1207
}
1199
1208
1200
- // Unlike B2, this example also does not work due to additional restrictions on shared.
1201
- shared struct D2
1209
+ struct B
1202
1210
{
1203
- // error: non-shared method S.__postblit is not callable using a shared object
1204
- S a;
1211
+ A a;
1212
+ }
1213
+
1214
+ void main()
1215
+ {
1216
+ shared B b1;
1217
+ auto b2 = b1;
1205
1218
}
1206
1219
---
1207
1220
)
1208
1221
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
1222
$(P Unions may not have fields that have postblits.)
1216
1223
1217
1224
$(H2 $(LEGACY_LNAME2 StructDestructor, struct-destructor, Struct Destructors))
0 commit comments