Skip to content

Commit

Permalink
Merge pull request #3459 from 9rnsr/fix8373
Browse files Browse the repository at this point in the history
Issue 8373 - IFTI fails on overloading of function vs non function template
  • Loading branch information
WalterBright committed Apr 19, 2014
2 parents dd0cf86 + c542416 commit c877142
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/template.c
Expand Up @@ -2255,6 +2255,8 @@ void functionResolve(Match *m, Dsymbol *dstart, Loc loc, Scope *sc,
m->last = MATCHnomatch;
return 1;
}
//printf("td = %s\n", td->toChars());

FuncDeclaration *f;
f = td->onemember ? td->onemember->isFuncDeclaration() : NULL;
if (!f)
Expand Down Expand Up @@ -2338,6 +2340,22 @@ void functionResolve(Match *m, Dsymbol *dstart, Loc loc, Scope *sc,
if (mfa < m->last)
return 0;

if (mta < ta_last) goto Ltd_best2;
if (mta > ta_last) goto Ltd2;

if (mfa < m->last) goto Ltd_best2;
if (mfa > m->last) goto Ltd2;

Lambig2: // td_best and td are ambiguous
//printf("Lambig2\n");
m->nextf = fd;
m->count++;
return 0;

Ltd_best2:
return 0;

Ltd2:
// td is the new best match
assert(td->scope);
td_best = td;
Expand Down
23 changes: 23 additions & 0 deletions test/fail_compilation/fail8373.d
@@ -0,0 +1,23 @@
/*
TEST_OUTPUT:
---
fail_compilation/fail8373.d(21): Error: fail8373.fun1 called with argument types (int) matches both:
fail_compilation/fail8373.d(15): fail8373.fun1!().fun1!(int).fun1(int)
and:
fail_compilation/fail8373.d(16): fail8373.fun1!(int).fun1(int)
fail_compilation/fail8373.d(22): Error: fail8373.fun2 called with argument types (int) matches both:
fail_compilation/fail8373.d(18): fail8373.fun2!(int).fun2(int)
and:
fail_compilation/fail8373.d(19): fail8373.fun2!().fun2!(int).fun2(int)
---
*/

template fun1(a...) { auto fun1(T...)(T args){ return 1; } }
auto fun1(T...)(T args){ return 2; }

auto fun2(T...)(T args){ return 2; }
template fun2(a...) { auto fun2(T...)(T args){ return 1; } }

enum x1 = fun1(0);
enum x2 = fun2(0);

0 comments on commit c877142

Please sign in to comment.