https://issues.dlang.org/show_bug.cgi?id=14161
[email protected] changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |[email protected] --- Comment #7 from [email protected] --- (In reply to Ketmar Dark from comment #6) > here compiler should issue warning that "global 'f' chosen for UFCS instead > of local one". yes, this is by spec, but sometimes people forgetting about > this and expecting local call. This code prints "foo2" without warnings and errors: import std.stdio; void foo() { writeln("foo1"); } void main() { void foo() { writeln("foo2"); } foo(); } while this gives a shadowing error message: struct Foo { int x; } void main() { int x; Foo f; with (f) x++; } test.d(6): Error: with symbol test.Foo.x is shadowing local symbol test.main.x In theory this looks like the first case, where a local function (pointer) silently shadows a module-level function: import std.stdio; void foo(int a) { writeln("it's a function! : ", a); } void main() { auto foo = (int a) { writeln("It's a variable! : ", a); }; 5.foo(); foo(5); } But this behaviour looks a little surprising. So perhaps in this case specifc it's better to give a shadowing error (with a warning/deprecation phase first), to avoid ambiguity. Like with() when no actual ambiguity is present in the code, no error message should be generated. --
