Symbol lookup failed in imported module
rumbu via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sun Oct 2 13:12:16 PDT 2016
module module1;
void foo(string s) {}
----------------------
module module2;
import module1;
void foo(int i)
{
foo("abc"); //error - function foo(int) is not callable using
argument types(string)
}
Ok, this can be easily solved using "alias foo = module1.foo",
but according to the documentation "Symbol lookup stops as soon
as a symbol is found". I think, in this case, this is too soon,
clearly foo(string) does not match foo(int), there is no
ambiguity.
Is this a bug, or intended behaviour? If it's intended behaviour,
it can lead to unintended effects if the overloads are not very
different:
module module1;
void foo(uint x) {}
----------------------
module module2;
import module1;
void foo(ulong x)
{
foo(cast(uint)x);
//the developper thinks that this will call foo(uint) declared
in module1
//Instead foo(ulong) will be called recursively until a nice
stack overflow will occur.
}
More information about the Digitalmars-d-learn
mailing list