Skip to content

Commit

Permalink
fix Issue 7933 - Illegal interaction of templates
Browse files Browse the repository at this point in the history
  • Loading branch information
9rnsr committed Apr 18, 2012
1 parent 6c5ec11 commit ec4041f
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/template.c
Expand Up @@ -2974,6 +2974,10 @@ MATCH TypeInstance::deduceType(Scope *sc,
}
else if (e1 && e2)
{
e1 = e1->optimize(WANTvalue | WANTinterpret);

//printf("e1 = %s, type = %s %d\n", e1->toChars(), e1->type->toChars(), e1->type->ty);
//printf("e2 = %s, type = %s %d\n", e2->toChars(), e2->type->toChars(), e2->type->ty);
if (!e1->equals(e2))
{ if (e2->op == TOKvar)
{
Expand All @@ -2983,7 +2987,13 @@ MATCH TypeInstance::deduceType(Scope *sc,
j = templateIdentifierLookup(((VarExp *)e2)->var->ident, parameters);
goto L1;
}
goto Lnomatch;
if (!e2->implicitConvTo(e1->type))
goto Lnomatch;

e2 = e2->implicitCastTo(sc, e1->type);
e2 = e2->optimize(WANTvalue | WANTinterpret);
if (!e1->equals(e2))
goto Lnomatch;
}
}
else if (e1 && t2 && t2->ty == Tident)
Expand Down
20 changes: 20 additions & 0 deletions test/runnable/template9.d
Expand Up @@ -1178,6 +1178,25 @@ void test7873()
bar(&i);
}

/**********************************/
// 7933

struct Boo7933(size_t dim){int a;}
struct Baa7933(size_t dim)
{
Boo7933!dim a;
//Boo7933!1 a; //(1) This version causes no errors
}

auto foo7933()(Boo7933!1 b){return b;}
//auto fuu7933(Boo7933!1 b){return b;} //(2) This line neutralizes the error

void test7933()
{
Baa7933!1 a; //(3) This line causes the error message
auto b = foo7933(Boo7933!1(1));
}

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

int main()
Expand Down Expand Up @@ -1226,6 +1245,7 @@ int main()
test11b();
test7769();
test7873();
test7933();

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

0 comments on commit ec4041f

Please sign in to comment.