[Issue 20851] New: unverified template constraints dont work with IFTI

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu May 21 07:28:28 UTC 2020


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 at puremagic.com
          Reporter: b2.temp at 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

--


More information about the Digitalmars-d-bugs mailing list