Skip to content

Commit

Permalink
Issue 6910 - __traits(hasMember, "<name>") does not work, if template…
Browse files Browse the repository at this point in the history
… has alias param
  • Loading branch information
9rnsr committed Nov 12, 2011
1 parent feaf491 commit 8baaaf6
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/mtype.c
Original file line number Diff line number Diff line change
Expand Up @@ -7251,7 +7251,8 @@ Expression *TypeStruct::dotExp(Scope *sc, Expression *e, Identifier *ident)
e = e->semantic(sc);
return e;
}
if (d->needThis() && fd && fd->vthis)
else if (d->needThis() && fd && fd->vthis &&
fd->toParent2()->isStructDeclaration() == sym)
{
e = new DotVarExp(e->loc, new ThisExp(e->loc), d);
e = e->semantic(sc);
Expand Down
39 changes: 39 additions & 0 deletions test/runnable/xtest46.d
Original file line number Diff line number Diff line change
Expand Up @@ -3982,6 +3982,44 @@ void test6859()
printf("done.\n");
}

/***************************************************/
// 6910

template Test6910(alias i, B)
{
void fn()
{
foreach(t; B.Types)
{
switch(i)
{
case 0://IndexOf!(t, B.Types):
{
pragma(msg, __traits(allMembers, t));
pragma(msg, __traits(hasMember, t, "m"));
static assert(__traits(hasMember, t, "m")); // test
break;
}
default: {}
}
}
}
}
void test6910()
{
static struct Bag(S...)
{
alias S Types;
}
static struct A
{
int m;
}

int i;
alias Test6910!(i, Bag!(A)).fn func;
}

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

int main()
Expand Down Expand Up @@ -4176,6 +4214,7 @@ int main()
test6733();
test6813();
test6859();
test6910();

printf("Success\n");
return 0;
Expand Down

1 comment on commit 8baaaf6

@WalterBright
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is causing:

http://d.puremagic.com/issues/show_bug.cgi?id=7027

I'm working on a fix.

Please sign in to comment.