Skip to content

Commit 835610c

Browse files
authored
__traits(allMembers, Struct) should call dsymbolSemantic (dlang#22657)
Fixes dlang#22524.
1 parent c660dd7 commit 835610c

2 files changed

Lines changed: 19 additions & 4 deletions

File tree

compiler/src/dmd/traits.d

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1715,6 +1715,11 @@ Expression semanticTraits(TraitsExp e, Scope* sc)
17151715
errorSupplemental(e.loc, "`%s` must evaluate to either a module, a struct, an union, a class, an interface or a template instantiation", s.toChars());
17161716
return ErrorExp.get();
17171717
}
1718+
// https://issues.dlang.org/show_bug.cgi?id=13668
1719+
// https://github.com/dlang/dmd/issues/22524
1720+
// resolve forward references
1721+
if (sds.semanticRun < PASS.semanticdone)
1722+
sds.dsymbolSemantic(sc);
17181723

17191724
auto idents = new Identifiers();
17201725

@@ -1793,10 +1798,6 @@ Expression semanticTraits(TraitsExp e, Scope* sc)
17931798
auto cd = sds.isClassDeclaration();
17941799
if (cd && e.ident == Id.allMembers)
17951800
{
1796-
if (cd.semanticRun < PASS.semanticdone)
1797-
cd.dsymbolSemantic(null); // https://issues.dlang.org/show_bug.cgi?id=13668
1798-
// Try to resolve forward reference
1799-
18001801
void pushBaseMembersDg(ClassDeclaration cd)
18011802
{
18021803
for (size_t i = 0; i < cd.baseclasses.length; i++)
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/*
2+
TEST_OUTPUT:
3+
---
4+
S2: AliasSeq!("__dtor", "__xdtor", "opAssign")
5+
S3: AliasSeq!("field", "__xdtor", "opAssign")
6+
---
7+
*/
8+
9+
// allMembers should include __xdtor
10+
pragma(msg, "S2: ", __traits(allMembers, S2));
11+
pragma(msg, "S3: ", __traits(allMembers, S3));
12+
13+
static struct S2 { ~this() {} }
14+
static struct S3 { S2 field; }

0 commit comments

Comments
 (0)