Bug 7131 – [tdpl] Hijacking detected where it doesn't exist
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
Other
OS
Mac OS X
Creation time
2011-12-18T17:49:00Z
Last change time
2012-01-20T09:38:30Z
Assigned to
code
Creator
andrei
Comments
Comment #0 by andrei — 2011-12-18T17:49:49Z
import std.regex;
//import std.array;
import std.string;
void main() {
string sentence;
auto words = split(sentence, regex("[ \t,.;:?]+"));
}
The only matching definition of split is in std.regex. However, the compiler reports:
Error: std.regex.split(String,RegEx) if (isSomeString!(String) && is(RegEx == Regex!(BasicElementOf!(String)))) at /Users/aalexandre/code/d/phobos/std/regex.d(6757) conflicts with std.string.split at /Users/aalexandre/code/d/phobos/std/string.d(70)
That is due to an import via alias. The bug occurs only when the symbol is imported indirectly, which is what std.string does. Uncommenting the std.array import and commenting out the std.string import makes the code work.
Comment #1 by code — 2011-12-22T12:34:12Z
Shouldn't this rather error when importing std.array.
I thought you must declare an overloadset to allow ADL.
alias std.regex.split split;
alias std.array.split split;
Comment #2 by code — 2012-01-16T18:10:21Z
Can you elaborate on why this should work.
There is a related bug w.r.t. buggy private overload resolution.
http://d.puremagic.com/issues/show_bug.cgi?id=5422
But here both functions/symbols imported are public.
Comment #3 by code — 2012-01-18T11:27:48Z
OK, std.string and std.regex should implicitly form
two overload sets. As the resolved set in std.string
is empty std.regex.split should be called.
http://www.d-programming-language.org/hijack.html
I will take a look at this when I find some time.
Comment #4 by code — 2012-01-20T07:39:53Z
Doesn't fail any longer, but I'll still have a look what went wrong/resolved it.
Comment #5 by code — 2012-01-20T09:38:30Z
Selective imports used to be added to the importing
module as an alias. The compiler does not generate
an overload set for aliased symbols, thus failed to
resolve this.
Fixed by:
https://github.com/D-Programming-Language/dmd/commit/dc5ab5ca6e00975cb836dabb00fa602cb7688ae2
The fix is not complete as it misses cases with nested
overload sets and aliases but I'll open a separate bug
report for that.