Local imports hide local symbols
Timon Gehr via Digitalmars-d
digitalmars-d at puremagic.com
Tue Sep 23 15:45:24 PDT 2014
On 09/23/2014 09:01 PM, Peter Alexander wrote:
> On Tuesday, 23 September 2014 at 18:52:13 UTC, H. S. Teoh via
> Digitalmars-d wrote:
>> 1) Change lookup rules so that symbols pulled in by local import are
>> found last. Walter has stated that he disagrees with this approach
>> because it complicates symbol lookup rules.
>
> This.
Agreed, but only if this is implemented such that more deeply nested
imports do not shadow less deeply nested imports.
I.e. if modules 'a' and 'b' both declare variables 'foo', then:
import a;
int fun(int foo){
import b; // fine
return foo; // fine, refers to parameter
}
auto gun(){
import b;
return foo; // error, could be a.foo or b.foo
}
More information about the Digitalmars-d
mailing list