March 10, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1049

           Summary: Template specialization via delegate parameters
           Product: D
           Version: 1.007
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla@digitalmars.com
        ReportedBy: gavrilyak@gmail.com


If template function has delegate argument the type of this argument is not
used when deducting the right function to use.
Compiler gives error about conflicting templates
At the same time compiler refuses to accept one such template instead of
another, so it looks like 2 different templates to it.

Example

T[] filter (T) (T[] me, bool delegate (T) predicate)  {
  T[] result;
  foreach (it; me)
    if (predicate(it))
      result ~= it;
  return result;
}

T[] filter (T) (T[] me, bool delegate (T,int) predicate)  {
  T[] result;
  foreach (i, it; me)
    if (predicate(it, i))
      result ~= it;
  return result;
}

void main(){
   int[] arr   = [1,2,3,4];
   auto gt2    = filter(arr, (int it){return it>3;});
   auto first2 = filter(arr, (int it,int i){return i<2;});
}

This code produces compiler error
>>template tdel.filter(T) conflicts with tdel.filter(T) at tdel.d(1)

Changing first filter to _filter give another error
tdel.d(19): template tdel.filter(T) does not match any template declaration
tdel.d(19): template tdel.filter(T) cannot deduce template function from
argument types (int[],bool delegate(int it))


So it seems compiler knows that functions are different and cannot use one instead of another, so there is no conflict here.


-- 

March 14, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1049


gavrilyak@gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |INVALID




------- Comment #1 from gavrilyak@gmail.com  2007-03-14 14:43 -------
Issue is invalid, that is how templates type resolution currently work. Maybe this needs to be feature request, but not a bug.


--