Warning on template parameter identifier shadowing?

Johan j at j.nl
Wed Aug 5 11:12:53 UTC 2020


Hi all,

I just discovered a silly programming error on my side. Stripped 
down, it looks like this:
```
template foo(T) {
     pragma(msg, __LINE__, ": ", T);

     // This should not have the "(T)"
     void foo(T)(T i) {
         pragma(msg, __LINE__, ": ", T);
     }
}

void main()
{
     foo!long(1);
}
```
which outputs
2: long
5: int
(https://d.godbolt.org/z/8K6sjc)

I made a template inside a template, where I intended to make 
just one eponymous template.

What do you think about adding a warning about shadowing of an 
outer template parameter by an inner template parameter name?

cheers,
   Johan




More information about the Digitalmars-d mailing list