Skip to content

Commit

Permalink
fix Issue 10082 - ICE(e2ir.c) Multiple mixin template instantiations …
Browse files Browse the repository at this point in the history
…are not checked
  • Loading branch information
9rnsr committed Oct 2, 2013
1 parent bd75cde commit 6e6e34a
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/init.c
Expand Up @@ -1060,17 +1060,17 @@ Type *ExpInitializer::inferType(Scope *sc)

// Give error for overloaded function addresses
if (exp->op == TOKsymoff)
{ SymOffExp *se = (SymOffExp *)exp;
{
SymOffExp *se = (SymOffExp *)exp;
if (se->hasOverloads && !se->var->isFuncDeclaration()->isUnique())
{
exp->error("cannot infer type from overloaded function symbol %s", exp->toChars());
return Type::terror;
}
}

// Give error for overloaded function addresses
if (exp->op == TOKdelegate)
{ DelegateExp *se = (DelegateExp *)exp;
{
DelegateExp *se = (DelegateExp *)exp;
if (se->hasOverloads &&
se->func->isFuncDeclaration() &&
!se->func->isFuncDeclaration()->isUnique())
Expand All @@ -1079,6 +1079,15 @@ Type *ExpInitializer::inferType(Scope *sc)
return Type::terror;
}
}
if (exp->op == TOKaddress)
{
AddrExp *ae = (AddrExp *)exp;
if (ae->e1->op == TOKoverloadset)
{
exp->error("cannot infer type from overloaded function symbol %s", exp->toChars());
return Type::terror;
}
}

Type *t = exp->type;
if (!t)
Expand Down
25 changes: 25 additions & 0 deletions test/fail_compilation/fail10082.d
@@ -0,0 +1,25 @@
/*
TEST_OUTPUT:
---
fail_compilation/fail10082.d(24): Error: cannot infer type from overloaded function symbol &foo
---
*/

mixin template T()
{
int foo()
{
return 0;
}
}

class A
{
mixin T;
mixin T;
}

void main()
{
auto x = &A.foo;
}

0 comments on commit 6e6e34a

Please sign in to comment.