Skip to content

Commit

Permalink
Fix inferAggregate
Browse files Browse the repository at this point in the history
  • Loading branch information
9rnsr committed Jan 21, 2013
1 parent 460c512 commit c16d6bd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/opover.c
Expand Up @@ -1259,6 +1259,8 @@ int ForeachStatement::inferAggregate(Scope *sc, Dsymbol *&sapply)
int sliced = 0;
#endif
Type *tab;
Type *att = NULL;
Expression *org_aggr = aggr;
AggregateDeclaration *ad;

while (1)
Expand All @@ -1270,6 +1272,10 @@ int ForeachStatement::inferAggregate(Scope *sc, Dsymbol *&sapply)
goto Lerr;

tab = aggr->type->toBasetype();
if (att == tab)
{ aggr = org_aggr;
goto Lerr;
}
switch (tab->ty)
{
case Tarray:
Expand Down Expand Up @@ -1315,6 +1321,8 @@ int ForeachStatement::inferAggregate(Scope *sc, Dsymbol *&sapply)

if (ad->aliasthis)
{
if (!att && tab->checkAliasThisRec())
att = tab;
aggr = new DotIdExp(aggr->loc, aggr, ad->aliasthis->ident);
continue;
}
Expand Down
6 changes: 6 additions & 0 deletions test/runnable/aliasthis.d
Expand Up @@ -330,6 +330,12 @@ void test7()
static assert(!__traits(compiles, s0 += s3)); // e2
static assert(!__traits(compiles, c1 += s1)); // e1 + e2
static assert(!__traits(compiles, c3 += s3)); // e1 + e2

// ForeachStatement::inferAggregate
static assert(!__traits(compiles, { foreach (e; s1){} }));
static assert(!__traits(compiles, { foreach (e; s3){} }));
static assert(!__traits(compiles, { foreach (e; c1){} }));
static assert(!__traits(compiles, { foreach (e; c3){} }));
}

/***************************************************/
Expand Down

0 comments on commit c16d6bd

Please sign in to comment.