Warning on template parameter identifier shadowing?
Paul Backus
snarwin at gmail.com
Wed Aug 5 17:27:44 UTC 2020
On Wednesday, 5 August 2020 at 16:57:49 UTC, Steven Schveighoffer
wrote:
> In essence, this is no different than erroring on shadowing of
> function variables, which could also be allowed, but saves a
> lot of trouble. You can look at it more as a "hey D, you have
> this position on variable names, but not on template parameter
> names, why the inconsistency?"
The case you point out here is the exception, not the rule. D
allows shadowing for everything *except* local variables in
functions. The most consistent thing to do would be to allow it
everywhere, period; presumably an exception was made because that
specific type of shadowing was thought to be particularly
error-prone.
Note that the exception does not apply to *parameters* of nested
functions, which is the analogous case here:
void foo(int x) {
void bar(int x) {} // ok
}
More information about the Digitalmars-d
mailing list