Skip to content

Commit

Permalink
fix Issue 14357 - Match on specType does not check the conflict with …
Browse files Browse the repository at this point in the history
…already deduced template arguments
  • Loading branch information
9rnsr committed Mar 29, 2015
1 parent 55c0dd9 commit 94f8915
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 5 deletions.
22 changes: 17 additions & 5 deletions src/template.c
Expand Up @@ -4774,7 +4774,7 @@ MATCH TemplateTypeParameter::matchArg(Scope *sc, RootObject *oarg,
size_t i, TemplateParameters *parameters, Objects *dedtypes,
Declaration **psparam)
{
//printf("TemplateTypeParameter::matchArg()\n");
//printf("TemplateTypeParameter::matchArg('%s')\n", ident->toChars());
MATCH m = MATCHexact;
Type *ta = isType(oarg);
if (!ta)
Expand All @@ -4800,7 +4800,19 @@ MATCH TemplateTypeParameter::matchArg(Scope *sc, RootObject *oarg,
if (m2 < m)
m = m2;
if ((*dedtypes)[i])
ta = (Type *)(*dedtypes)[i];
{
Type *t = (Type *)(*dedtypes)[i];

if (dependent && !t->equals(ta)) // Bugzilla 14357
goto Lnomatch;

/* This is a self-dependent parameter. For example:
* template X(T : T*) {}
* template X(T : S!T, alias S) {}
*/
//printf("t = %s ta = %s\n", t->toChars(), ta->toChars());
ta = t;
}
}
else
{
Expand Down Expand Up @@ -4991,7 +5003,7 @@ MATCH TemplateAliasParameter::matchArg(Scope *sc, RootObject *oarg,
size_t i, TemplateParameters *parameters, Objects *dedtypes,
Declaration **psparam)
{
//printf("TemplateAliasParameter::matchArg()\n");
//printf("TemplateAliasParameter::matchArg('%s')\n", ident->toChars());
MATCH m = MATCHexact;
Type *ta = isType(oarg);
RootObject *sa = ta && !ta->deco ? NULL : getDsymbol(oarg);
Expand Down Expand Up @@ -5241,7 +5253,7 @@ MATCH TemplateValueParameter::matchArg(Scope *sc, RootObject *oarg,
size_t i, TemplateParameters *parameters, Objects *dedtypes,
Declaration **psparam)
{
//printf("TemplateValueParameter::matchArg()\n");
//printf("TemplateValueParameter::matchArg('%s')\n", ident->toChars());

MATCH m = MATCHexact;

Expand Down Expand Up @@ -5468,7 +5480,7 @@ MATCH TemplateTupleParameter::matchArg(Scope *sc, RootObject *oarg,
size_t i, TemplateParameters *parameters, Objects *dedtypes,
Declaration **psparam)
{
//printf("TemplateTupleParameter::matchArg()\n");
//printf("TemplateTupleParameter::matchArg('%s')\n", ident->toChars());
Tuple *ovar = isTuple(oarg);
if (!ovar)
return MATCHnomatch;
Expand Down
12 changes: 12 additions & 0 deletions test/runnable/template9.d
Expand Up @@ -4399,6 +4399,18 @@ void test14174()
accepter14174b(); // error
}

/******************************************/
// 14357

template Qux14357(T : U*, U : V*, V)
{
pragma(msg, T); // no match <- float**
pragma(msg, U); // no match <- float*
pragma(msg, V); // no match <- int
enum Qux14357 = T.sizeof + V.sizeof;
}
static assert(!__traits(compiles, Qux14357!(float**, int*)));

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

int main()
Expand Down

0 comments on commit 94f8915

Please sign in to comment.