www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 20851] New: unverified template constraints dont work with IFTI

https://issues.dlang.org/show_bug.cgi?id=20851

          Issue ID: 20851
           Summary: unverified template constraints dont work with IFTI
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: diagnostic
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: b2.temp gmx.com

given the following code

---
struct Matrix(T) {}
struct Kernel(T) {}

void calculateKernelMatrix(K, T)(K!T kernel, Matrix!T data)
if (__traits(isTemplate, K))
{ }

void main()
{
    Matrix!float m;
    Kernel!float k;
    version (all)  calculateKernelMatrix(k,m);                           //
case 1
    version (none) calculateKernelMatrix!(typeof(m), typeof(k))(k,m);    //
case 2
}
---

for the case 1 we got

 /tmp/temp_7F8FE34BE6D0.d(16,26): Error: template
`runnable.calculateKernelMatrix` cannot deduce function from argument types
`!()(Kernel!float, Matrix!float)`, candidates are:
 /tmp/temp_7F8FE34BE6D0.d(8,6):        `calculateKernelMatrix(K, T)(K!T kernel,
Matrix!T data)` 
for case 2, dont forget to invert the versions...) we got
 /tmp/temp_7F8FE34BE6D0.d(17,5): Error: template instance
`runnable.calculateKernelMatrix!(Matrix!float, Kernel!float)` does not match
template declaration `calculateKernelMatrix(K, T)(K!T kernel, Matrix!T data)`
  with `K = Matrix!float,
       T = Kernel!float`
  must satisfy the following constraint:
 `       __traits(isTemplate, K)`
the for case 1 we could expect the same diagnostic as in case 2 --
May 21 2020