Is this a known issue in Phobos/DMD?

Chris wendlec at tcd.ie
Sun Jan 6 06:15:42 PST 2013


On Sunday, 6 January 2013 at 00:49:06 UTC, Jonathan M Davis wrote:
>
>> 2. Now the function from std.algorithm that becomes visible, 
>> shadows the
>> local argument count. Is this expected behavior? If not, has 
>> it already
>> been reported as a bug? At the minimum I expect better error 
>> message here.
>
> _That_ is definitely a bug. Symbols local to a module are 
> supposed to have
> precedence over imported symbols, so there shouldn't be any 
> symbol conflicts
> when using a symbol local to a module, and local variables have 
> precedence
> over module-level symbols, so it's definitely broken if a local 
> import causes
> conflicts with a local variable. I have no idea if it's been 
> reported though.
> You'd have to search bugzilla:
>
> http://d.puremagic.com/issues
>
> - Jonathan M Davis

There is no shadowing, if the import statement is outside the 
function

void main() {                   // 1
  foo(4);                       // 2
}                               // 3
import std.string;               // 4
void foo(int count) {           // 5
              // 6
  format("%s", count);          // 7
}

This means that the local variable still has precedence over the 
imported one. However, if it is inside the function the imported 
variable is treated as local, as in "last one in closes the door"?


More information about the Digitalmars-d mailing list