From c542416605ea13c5601a586c21e58a4332f7819c Mon Sep 17 00:00:00 2001 From: k-hara Date: Wed, 16 Apr 2014 14:06:45 +0900 Subject: [PATCH] fix Issue 8373 - IFTI fails on overloading of function vs non function template --- src/template.c | 18 ++++++++++++++++++ test/fail_compilation/fail8373.d | 23 +++++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 test/fail_compilation/fail8373.d diff --git a/src/template.c b/src/template.c index 9e8a1ebdfaeb..5722198e5cd9 100644 --- a/src/template.c +++ b/src/template.c @@ -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) @@ -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; diff --git a/test/fail_compilation/fail8373.d b/test/fail_compilation/fail8373.d new file mode 100644 index 000000000000..2bb29b0bfacd --- /dev/null +++ b/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); +