Skip to content

Commit bd8bc44

Browse files
RazvanN7thewilsonator
authored andcommitted
Spec change for Issue 18474
1 parent 104d354 commit bd8bc44

File tree

1 file changed

+27
-20
lines changed

1 file changed

+27
-20
lines changed

spec/struct.dd

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1144,10 +1144,10 @@ void main()
11441144
$(P The postblits `__fieldPostblit` and `__aggrPostblit`
11451145
are generated without any implicit qualifiers and are not considered
11461146
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.)
11511151

11521152
$(SPEC_RUNNABLE_EXAMPLE_FAIL
11531153
---
@@ -1186,32 +1186,39 @@ immutable struct C2
11861186
{
11871187
S a;
11881188
}
1189+
---
11891190

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
11921201
{
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;
11961202
this(this)
1197-
{ }
1203+
{
1204+
import std.stdio : writeln;
1205+
writeln("the shared postblit was called");
1206+
}
11981207
}
11991208

1200-
// Unlike B2, this example also does not work due to additional restrictions on shared.
1201-
shared struct D2
1209+
struct B
12021210
{
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;
12051218
}
12061219
---
12071220
)
12081221

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-
12151222
$(P Unions may not have fields that have postblits.)
12161223

12171224
$(H2 $(LEGACY_LNAME2 StructDestructor, struct-destructor, Struct Destructors))

0 commit comments

Comments
 (0)