Skip to content

Commit

Permalink
Merge pull request #4499 from 9rnsr/fix14290
Browse files Browse the repository at this point in the history
Issue 14290 - is-expression accepts instantiation of already instantiated template
  • Loading branch information
WalterBright committed Mar 25, 2015
2 parents 48086f7 + 4a90c00 commit 5c1fedc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/template.c
Expand Up @@ -3703,10 +3703,15 @@ MATCH deduceType(RootObject *o, Scope *sc, Type *tparam, TemplateParameters *par
if (tx)
{
s = tx->toDsymbol(sc);
if (s)
if (TemplateInstance *ti = s ? s->parent->isTemplateInstance() : NULL)
{
TemplateInstance *ti = s->parent->isTemplateInstance();
s = ti ? ti->tempdecl : NULL;
// Bugzilla 14290: Try to match with ti->tempecl,
// only when ti is an enclosing instance.
Dsymbol *p = sc->parent;
while (p && p != ti)
p = p->parent;
if (p)
s = ti->tempdecl;
}
}
if (s)
Expand Down
7 changes: 7 additions & 0 deletions test/runnable/template9.d
Expand Up @@ -1592,6 +1592,13 @@ void test12()
t.foo!Tuple12();
}

/**********************************/
// 14290

struct Foo14290(int i) {}
alias Foo14290a = Foo14290!1;
static assert(!is(Foo14290!2 == Foo14290a!T, T...));

/**********************************/
// 8125

Expand Down

0 comments on commit 5c1fedc

Please sign in to comment.