Skip to content

Commit 866ad49

Browse files
authored
Merge pull request #2325 from RazvanN7/update_18474
Spec change for Issue 18474 merged-on-behalf-of: Nicholas Wilson <thewilsonator@users.noreply.github.com>
2 parents 3a66f2d + ce3f990 commit 866ad49

File tree

1 file changed

+28
-20
lines changed

1 file changed

+28
-20
lines changed

spec/struct.dd

Lines changed: 28 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,40 @@ immutable struct C2
11861186
{
11871187
S a;
11881188
}
1189+
---
1190+
)
11891191

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
11921202
{
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;
11961203
this(this)
1197-
{ }
1204+
{
1205+
import std.stdio : writeln;
1206+
writeln("the shared postblit was called");
1207+
}
11981208
}
11991209

1200-
// Unlike B2, this example also does not work due to additional restrictions on shared.
1201-
shared struct D2
1210+
struct B
12021211
{
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;
12051219
}
12061220
---
12071221
)
12081222

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

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

0 commit comments

Comments
 (0)