[Issue 22720] New: Overload of template and alias to template instantiation that is also a template fails
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Jan 31 15:34:27 UTC 2022
https://issues.dlang.org/show_bug.cgi?id=22720
Issue ID: 22720
Summary: Overload of template and alias to template
instantiation that is also a template fails
Product: D
Version: D2
Hardware: x86_64
OS: Linux
Status: NEW
Severity: normal
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: default_357-line at yahoo.de
Consider the following code:
```
template foo(T) {
U foo(U : T)() { return T.init; }
}
float bar(U : float)() { return 0.0f; }
alias bar = foo!int;
void main() {
assert(bar!int == 0);
}
```
Ie. template function bar is overloaded with an alias to foo's instance
foo!int, which is itself a template function.
This results in:
onlineapp.d(6): Error: template instance `foo!int` `foo!int` forward references
template declaration `foo(T)`
onlineapp.d(6): Error: alias `onlineapp.bar` conflicts with template
`onlineapp.bar(U : float)()` at onlineapp.d(5)
Note that this works fine if foo is just a function, or if `alias bar` is moved
before `float bar`.
--
More information about the Digitalmars-d-bugs
mailing list