Skip to content

Commit

Permalink
fix Issue 14844 - __traits(allMembers) must not visit yet not instant…
Browse files Browse the repository at this point in the history
…iated template members
  • Loading branch information
9rnsr committed Jul 30, 2015
1 parent 7e53100 commit 9e6ad65
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/traits.c
Expand Up @@ -945,19 +945,18 @@ Expression *semanticTraits(TraitsExp *e, Scope *sc)
goto Ldimerror;
RootObject *o = (*e->args)[0];
Dsymbol *s = getDsymbol(o);
ScopeDsymbol *sds;
if (!s)
{
e->error("argument has no members");
goto Lfalse;
}
Import *import;
if ((import = s->isImport()) != NULL)
if (Import *imp = s->isImport())
{
// Bugzilla 9692
sds = import->mod;
s = imp->mod;
}
else if ((sds = s->isScopeDsymbol()) == NULL)
ScopeDsymbol *sds = s->isScopeDsymbol();
if (!sds || sds->isTemplateDeclaration())
{
e->error("%s %s has no members", s->kind(), s->toChars());
goto Lfalse;
Expand Down
21 changes: 21 additions & 0 deletions test/fail_compilation/ice14844.d
@@ -0,0 +1,21 @@
/*
TEST_OUTPUT:
---
fail_compilation/ice14844.d(20): Error: template opDispatch(string name) has no members
---
*/

struct Typedef
{
template opDispatch(string name)
{
static if (true)
{
}
}
}

void runUnitTestsImpl()
{
auto x = [__traits(allMembers, Typedef.opDispatch)];
}

0 comments on commit 9e6ad65

Please sign in to comment.