Thread overview
Partially applied template alias messes up template inferance
Oct 14, 2020
Jonathan Levi
Oct 14, 2020
Paul Backus
Oct 15, 2020
Jonathan Levi
October 14, 2020
This gist gives a full example: https://gist.github.com/run-dlang/a28372ffaa05c3f2a4d852ca4b0a7bf5  (See the compiler error.)

In essence:
```
struct Vec(T, size_t size) {}
alias Vec2(T) = Vec(T, size);
void fun(T)(Vec2!T vec) {}

void main() {
    // Error: template fun cannot deduce function from argument types !()(Vec!(float, 2LU))
    fun(Vec2!float());
}
```

The template function can be written without using the alias and everything works great:
```
void fun(T)(Vec!(T,2) vec) {}
```

Is this fixable in the language, or is it just not feasible?




October 14, 2020
On Wednesday, 14 October 2020 at 02:37:25 UTC, Jonathan Levi wrote:
> This gist gives a full example: https://gist.github.com/run-dlang/a28372ffaa05c3f2a4d852ca4b0a7bf5  (See the compiler error.)
>
> In essence:
> ```
> struct Vec(T, size_t size) {}
> alias Vec2(T) = Vec(T, size);
> void fun(T)(Vec2!T vec) {}
>
> void main() {
>     // Error: template fun cannot deduce function from argument types !()(Vec!(float, 2LU))
>     fun(Vec2!float());
> }
> ```
>
> The template function can be written without using the alias and everything works great:
> ```
> void fun(T)(Vec!(T,2) vec) {}
> ```
>
> Is this fixable in the language, or is it just not feasible?

This is a known limitation of template argument deduction:

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

Attempts have been made to fix it in the past, but so far none have succeeded. It's probably not feasible given the compiler's current implementation of templates.
October 15, 2020
On Wednesday, 14 October 2020 at 03:29:50 UTC, Paul Backus wrote:
> This is a known limitation of template argument deduction:
>
> https://issues.dlang.org/show_bug.cgi?id=1807
>
> Attempts have been made to fix it in the past, but so far none have succeeded. It's probably not feasible given the compiler's current implementation of templates.

Thanks, that is what I know.  Bummer.