www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Renamed import for current module

Consider following program abc.def:

import std.stdio;

void main()
{
     foo();
     abc.foo();
}

string val = "abc.val";

void foo()
{
     writeln(abc.val);
}

It produces expected results. Now create new module def.d:

import std.stdio;

void foo()
{
      writeln("def.foo");
}

 property string val()
{
     writeln("hijack");
     return "def.val";
}

add "import abc=def" in abc.d and compile both.

I expected that such feature (module abc; import abc=def;) is not 
allowed.
Any reference to "abc" namespace actually points to def module. 
Dmd (2.060)
even accepts ambiguous calls to abc.foo() when both abc.foo() and 
def.foo() exist. It looks like entire namespace "abc" is replaced 
with "def".
Is this a bug or a feature?

Also, following question arise:
Given statement "How basic imports work is that first a name is 
searched for in the current namespace. If it is not found, then 
it is looked for in the imports. If it is found uniquely among 
the imports, then that is used. If it is in more than one import, 
an error occurs." from modules spec page, what actually mean 
"current namespace": only "." or "modulename." too?
Aug 06 2012