Skip to content

Commit

Permalink
fix Issue 7583 - [CTFE] ICE with tuple and alias this
Browse files Browse the repository at this point in the history
  • Loading branch information
9rnsr committed Feb 29, 2012
1 parent ca0d71c commit efd4711
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/expression.c
Original file line number Diff line number Diff line change
Expand Up @@ -9996,7 +9996,8 @@ Expression *AssignExp::semantic(Scope *sc)
TypeTuple *tt = (TypeTuple *)e1->type;

Identifier *id = Lexer::uniqueId("__tup");
VarDeclaration *v = new VarDeclaration(e2->loc, NULL, id, new ExpInitializer(e2->loc, e2));
ExpInitializer *ei = new ExpInitializer(e2->loc, e2);
VarDeclaration *v = new VarDeclaration(e2->loc, NULL, id, ei);
v->storage_class = STCctfe | STCref | STCforeach;
Expression *ve = new VarExp(e2->loc, v);
ve->type = e2->type;
Expand Down
4 changes: 2 additions & 2 deletions src/opover.c
Original file line number Diff line number Diff line change
Expand Up @@ -1141,7 +1141,7 @@ Expression *BinAssignExp::op_overload(Scope *sc)
/* Rewrite (e1 op e2) as:
* (e1.aliasthis op e2)
*/
Expression *e1 = new DotIdExp(loc, this->e1, ad1->aliasthis->ident);
Expression *e1 = new DotIdExp(loc, this->e1->syntaxCopy(), ad1->aliasthis->ident);
Expression *e = copy();
((BinExp *)e)->e1 = e1;
e = e->trySemantic(sc);
Expand All @@ -1155,7 +1155,7 @@ Expression *BinAssignExp::op_overload(Scope *sc)
/* Rewrite (e1 op e2) as:
* (e1 op e2.aliasthis)
*/
Expression *e2 = new DotIdExp(loc, this->e2, ad2->aliasthis->ident);
Expression *e2 = new DotIdExp(loc, this->e2->syntaxCopy(), ad2->aliasthis->ident);
Expression *e = copy();
((BinExp *)e)->e2 = e2;
e = e->trySemantic(sc);
Expand Down
20 changes: 20 additions & 0 deletions test/runnable/xtest46.d
Original file line number Diff line number Diff line change
Expand Up @@ -4692,6 +4692,26 @@ mixin template ProxyOf(alias a)
void test2(this Y)(){}
}

/***************************************************/
// 7583

template Tup7583(E...) { alias E Tup7583; }

struct S7583
{
Tup7583!(float, char) field;
alias field this;
this(int x) { }
}

int bug7583() {
S7583[] arr;
arr ~= S7583(0);
return 1;
}

static assert (bug7583());

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

int main()
Expand Down

0 comments on commit efd4711

Please sign in to comment.