// I.
void foo(V)(in V v)
{
}
// II.
void foo(Args...)(auto ref const Args args)
{
foo(args[0]);
}
void main()
{
foo(10);
}
-----
Deducing foo(10)
function arguments: rvalue int
I. - MATCHconst
II. - MATCHexact
picks II
-----
Deducing foo(args[0])
function arguments: lvalue const(int)
I. - MATCHexact
II. - MATCHexact
This is further disambiguated by leastAsSpecialized.
template.c(895):
/* A non-variadic template is more specialized than a
* variadic one.
*/
if (isVariadic() && !td2->isVariadic())
picks I
-----
We end up instantiating both functions with the same argument types.
Thus the mangling is the same and the linker will pick whatever he likes.
1. I think that variadic templates shouldn't be exact matches.
2. We shouldn't use tiebreakers but issue ambiguous errors.
A quick fix would be to change variadic templates to MATCHconvert as in
the attached patch.
But I think we should reduce the complexity of template matching rather
than patching it.
0001-use-MATCHconvert-for-variadic-templates.patch
Description: Binary data
_______________________________________________ dmd-beta mailing list [email protected] http://lists.puremagic.com/mailman/listinfo/dmd-beta
