Ambiguous template parameter names
user1234
user1234 at 12.nl
Wed May 2 23:12:00 UTC 2018
On Wednesday, 2 May 2018 at 20:32:43 UTC, jmh530 wrote:
> In the function below, there is a template parameter and a
> normal parameter both with the same name. However, the function
> returns the normal parameter. The template parameter is
> effectively ignored. I was surprised by this behavior.
>
> Is this a bug or intentional? I did not see it documented
> anywhere.
>
>
> ```
> int foo(int val)(int val)
> {
> return val;
> }
>
> void main()
> {
> assert(foo!1(2) == 2);
> }
> ```
i think this is a bug and that it should be reported. The main
problem is that you cant even use the val (the template parameter
one) in a static if.
More information about the Digitalmars-d-learn
mailing list