After simplifying a part of my code I found the following code cannot deduce the template arguments, but I have no clue why.

```d
void foo(L : T[L1][L2], uint L1, uint L2, T, R:
                T[L1])(const L left, const R right) {
        // Function
}

void bar(uint L)(float[L] l) {
        // Function
}

void main(string[] args) {
foo2([1.0f, 2, 3, 4, 5, 6, 7, 8]); // implicitly cast to float[8], works
        float[4][1] l = [[1, 2, 3, 4]];
foo!(typeof(l), 4, 1, float, float[4])(l, [1.0f, 2, 3, 4]); // also works foo(l, [1.0f, 2, 3, 4]); // cannot deduce function from argument types (?)
}
```

As one can see, implicitly casting array literals in templates works fine in the case of bar, as does explicit use of templates in the case of foo, but for some reason foo does not manage to deduce its arguments like bar does. The type of l is well known, and given the template, the type of R should thus be known as well. T[L1] should be deduced to float[4]. Did I make a mistake in the argument list? I know things like the order are sometimes issues, but that seems fine to me here. Seeing as bar functions fine (as does foo when R and right are removed) I'm at a loss.

Thanks you in advance!

Reply via email to