Consider these two imports:
a.d:
module a;
void foo(int) {}
b.d:
module b;
void foo(string) {}
Now, we import them and use them:
main.d:
import a;
import b;
void main()
{
foo(1);
foo("hi");
}
Works great. Now let's use a local import instead:
main.d:
import a;
void main()
{
import b;
foo(1);
foo("hi");
}
oops, doesn't work. Because b masks all other overloads for foo.
I have to say, this doesn't seem right. What I want when I import inside
a local scope is to treat all code in that scope as if I *had* imported
that module at module level.
I realize changing this would mean that existing code would break. But
what this does, effectively, is destroy any possibility to overload
functions across modules reliably.
See this regression: https://issues.dlang.org/show_bug.cgi?id=15179
How can we fix this? 'to' really *is* a UFCS function, it shouldn't be a
member. Do we just say "sorry, please make all your imports local"?
Another *horrendous* issue I have seen:
a.d:
module a;
void foo(int) {}
main.d:
void foo(string) {}
void main()
{
import main; // yes, you have to import main inside main
import a;
foo("hi");
}
Can we fix this?
-Steve