[Issue 2025] Inconsistent rules for instantiating templates with a tuple parameter

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Feb 1 05:27:37 PST 2012


http://d.puremagic.com/issues/show_bug.cgi?id=2025



--- Comment #10 from Stewart Gordon <smjg at iname.com> 2012-02-01 05:27:34 PST ---
(In reply to comment #9)
> For (T : int) to be preferred over (T), it must return a worse 
> match level for the unspecialized parameter.  Currently it will 
> return MATCHconvert for these parameters, and return MATCHexact 
> only when there is a (matching) spec type.

So MATCHexact means "the pattern can be matched only by this exact set of
arguments", and MATCHconvert means "this is one of various sets of arguments
that can match this pattern".

But then, surely, it would be rejecting the instantiation as ambiguous, not
picking the (A...) overload.

Really, it's a fundamental flaw in the compiler logic whereby it conflates two
essentially orthogonal concepts: exactness and specialisation.

A correct template instantiation algorithm would:
- see which template patterns match the instantiation exactly
- if none, see which template patterns match with implicit conversions
- of all the matches, determine which is most specialised

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list