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);
}
```

It's not a big per se. It's a consequence of the declaration expanding to the real template function form (I can't type it all out as I'm on my phone), thus the inner `val` from the function shadows the one from the template.

Reply via email to