Skip to content

Commit

Permalink
fix Issue 12880 - Wrong IFTI for string.init argument
Browse files Browse the repository at this point in the history
Consider matching between e->type->mod to tparam->mod in deduceExpType
  • Loading branch information
9rnsr committed Jun 8, 2014
1 parent 0b0bffa commit eef3ed6
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
21 changes: 19 additions & 2 deletions src/template.c
Expand Up @@ -4324,6 +4324,20 @@ MATCH deduceType(RootObject *o, Scope *sc, Type *tparam, TemplateParameters *par
if (i == IDX_NOTFOUND)
return false;

Type *t = e->type;
Type *tt;
if (unsigned char wx = wm ? deduceWildHelper(t, &tt, tparam) : 0)
{
*wm |= wx;
result = MATCHconst;
}
else
{
result = deduceTypeHelper(t, &tt, tparam);
}
if (result <= MATCHnomatch)
return true;

Type *at = (Type *)(*dedtypes)[i];
if (!at) // expression vs ()
{
Expand All @@ -4334,8 +4348,12 @@ MATCH deduceType(RootObject *o, Scope *sc, Type *tparam, TemplateParameters *par
* // 1: deduceType(oarg='1', tparam='T', ...)
* // T <= TypeTypeof(1)
*/
if (t != tt)
{
e = e->copy();
e->type = tt;
}
(*dedtypes)[i] = new TypeTypeof(e->loc, e);
result = MATCHexact; // TODO
}
else if (at->ty == Ttypeof) // expression vs expression
{
Expand All @@ -4359,7 +4377,6 @@ MATCH deduceType(RootObject *o, Scope *sc, Type *tparam, TemplateParameters *par
if (ec == condexp)
{
((TypeTypeof *)at)->exp = condexp;
result = MATCHexact; // TODO
}
}
else // expression vs type
Expand Down
6 changes: 6 additions & 0 deletions test/runnable/template9.d
Expand Up @@ -3447,6 +3447,12 @@ void test9708()
s.f(new Object);
}

/******************************************/
// 12880

void f12880(T)(in T value) { static assert(is(T == string)); }
void test12880() { f12880(string.init); }

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

int main()
Expand Down

0 comments on commit eef3ed6

Please sign in to comment.