This example compiles in 2.056
---
struct A(T)
{
T func(T)(T rhs)
{
return rhs;
}
}
void main()
{
A!(int) a;
a.func("test");
}
---
Comment #1 by lt.infiltrator — 2014-03-19T22:02:54Z
This could certainly be a source of unexpected bugs. Has anybody dug into this?
Comment #2 by qs.il.paperinik — 2023-12-12T11:40:29Z
The general sense of when shadowing a symbol is an error or not is if the symbol has an unambiguous way to be referenced. This expectation is broken when template parameters are shadowed:
```d
struct S(T)
{
alias T = int; // no error!?
T x;
pragma(msg, typeof(x)); // int
}
S!double unused;
```
Comment #3 by b2.temp — 2023-12-13T10:44:09Z
This is a bug given that you cant select the first definition.
However, this should works when T is an alias template parameter and that T is either a function or an overload set.
That is not the case now:
```d
struct S(alias T)
{
alias T = (int) => 0;
void test()
{
T(0.1); // Error: function literal `__lambda3(int __param_0)` is not callable
// using argument types `(double)`
T(1);
}
}
void main(string[] args)
{
S!((float) => 0) s1;
}
```
Comment #4 by b2.temp — 2023-12-16T18:23:53Z
*** Issue 14516 has been marked as a duplicate of this issue. ***
Comment #5 by robert.schadek — 2024-12-13T17:57:00Z