[Issue 14161] UFCS call does not abide by scope

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Tue Feb 10 07:50:18 PST 2015


https://issues.dlang.org/show_bug.cgi?id=14161

--- Comment #8 from Ketmar Dark <ketmar at ketmar.no-ip.org> ---
i don't think that shadowing globals should always generate warning. i believe
that it's enough to generate warning only when there is possible UFCS
shadowing.

so:

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

no warning.

but with uncommented `5.foo();` there should be a warning.

shadowing global functions with locals is not a big deal in a good written
code, but remembering that UFCS ignores locals and picks globals instead is
something that should better be told by the compiler.

--


More information about the Digitalmars-d-bugs mailing list