Skip to content

Commit

Permalink
Issue 7027 - Struct member trySemantic() regression in DMD Git master
Browse files Browse the repository at this point in the history
  • Loading branch information
WalterBright committed Dec 8, 2011
1 parent 0ebfc7f commit 9a2e87b
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
3 changes: 1 addition & 2 deletions src/mtype.c
Expand Up @@ -7273,8 +7273,7 @@ Expression *TypeStruct::dotExp(Scope *sc, Expression *e, Identifier *ident)
e = e->semantic(sc);
return e;
}
else if (d->needThis() && fd && fd->vthis &&
fd->toParent2()->isStructDeclaration() == sym)
else if (d->needThis() && fd && fd->vthis)
{
e = new DotVarExp(e->loc, new ThisExp(e->loc), d);
e = e->semantic(sc);
Expand Down
16 changes: 14 additions & 2 deletions src/traits.c
Expand Up @@ -258,9 +258,21 @@ Expression *TraitsExp::semantic(Scope *sc)
}

if (ident == Id::hasMember)
{ /* Take any errors as meaning it wasn't found
{
if (t)
{
Dsymbol *sym = t->toDsymbol(sc);
Dsymbol *sm = sym->search(loc, id, 0);
if (sm)
goto Ltrue;
}

/* Take any errors as meaning it wasn't found
*/
e = e->trySemantic(sc);
Scope *sc2 = sc->push();
//sc2->inHasMember++;
e = e->trySemantic(sc2);
sc2->pop();
if (!e)
{ if (global.gag)
{
Expand Down
7 changes: 7 additions & 0 deletions test/runnable/traits.d
Expand Up @@ -641,6 +641,13 @@ static assert(__traits(isSame, V6073, U6073)); // same instantiation == same ar

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

struct Foo7027 {
int a;
}
static assert(!__traits(compiles, { return Foo7027.a; }));

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

int main()
{
test1();
Expand Down

0 comments on commit 9a2e87b

Please sign in to comment.