Skip to content

Commit

Permalink
Merge pull request dlang#1902 from IgorStepanov/allmembersenum
Browse files Browse the repository at this point in the history
Fixes Issue 9939 allMembers trait doesn't returns members of nested anonymous enum
  • Loading branch information
9rnsr committed Apr 16, 2013
2 parents 73835a8 + c86e8b2 commit f7e81e8
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/traits.c
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,14 @@ Expression *TraitsExp::semantic(Scope *sc)

idents->push(sm->ident);
}
else
{
EnumDeclaration *ed = sm->isEnumDeclaration();
if (ed)
{
ScopeDsymbol::foreach(NULL, ed->members, &PushIdentsDg::dg, (Identifiers *)ctx);
}
}
return 0;
}
};
Expand Down
18 changes: 18 additions & 0 deletions test/runnable/traits.d
Original file line number Diff line number Diff line change
Expand Up @@ -1141,6 +1141,24 @@ void test9136()

/********************************************************/

struct Test25
{
int f;
enum /*Anonymous enum*/
{
A,
B
}
enum NamedEnum
{
C,
D
}
}

static assert([__traits(allMembers, Test25)] == ["f", "A", "B", "NamedEnum"]);
/********************************************************/

int main()
{
test1();
Expand Down

0 comments on commit f7e81e8

Please sign in to comment.