digitalmars.D.learn - Symbol lookup failed in imported module
- rumbu (31/31) Oct 02 2016 module module1;
- Lodovico Giaretta (4/5) Oct 02 2016 I think you'll find the following article really interesting. It
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. }
Oct 02 2016
On Sunday, 2 October 2016 at 20:12:16 UTC, rumbu wrote:[...]I think you'll find the following article really interesting. It talks exactly about what you are experiencing. http://dlang.org/hijack.html
Oct 02 2016