Local imports hide local symbols

monarch_dodra via Digitalmars-d digitalmars-d at puremagic.com
Tue Sep 23 12:47:59 PDT 2014


On Tuesday, 23 September 2014 at 19:18:08 UTC, H. S. Teoh via 
Digitalmars-d wrote:
> But this would cause a compile error:
>
> 	----mod.d----
> 	module mod;
> 	string x, y;
>
> 	----main.d----
> 	void main() {
> 		int x, y, z;
> 		import mod;
>
> 		x++;	// Error: ambiguous symbol 'x', could be local
> 			// variable 'x' or mod.x
> 	}
>
>
> T

How do you disambiguate to say "the x I want is the local one" ?

IMO, simply make it that local imports work like global ones, but 
scoped. Global imports don't have this issue, why should local 
imports have special rules?


More information about the Digitalmars-d mailing list