[Issue 14161] UFCS call does not abide by scope
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Tue Feb 10 08:37:24 PST 2015
https://issues.dlang.org/show_bug.cgi?id=14161
--- Comment #9 from Steven Schveighoffer <schveiguy at yahoo.com> ---
(In reply to bearophile_hugs from comment #7)
> 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.
Shadowing is only allowed on global scope. The reasons are simple:
1. You often have little control over what modules you import define.
2. You can use '.' to distinguish between your local symbol and the global one.
(In reply to Ketmar Dark from comment #8)
> 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.
I am not of the opinion that UFCS is so special we need to bend over backwards
to make it work in all cases. The underlying request that must be implemented
before we even consider adding a warning for a conflict is that you need to be
able to use UFCS on function pointers or even nested or member functions. I
don't think we should even do that, and without that, there isn't a point for a
warning here. There is always the possibility to use normal function call
syntax.
--
More information about the Digitalmars-d-bugs
mailing list