http://d.puremagic.com/issues/show_bug.cgi?id=8667

           Summary: selective import breaks normal overload resolution
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: critical
          Priority: P2
         Component: DMD
        AssignedTo: nob...@puremagic.com
        ReportedBy: dmitry.o...@gmail.com


--- Comment #0 from Dmitry Olshansky <dmitry.o...@gmail.com> 2012-09-16 
06:03:26 PDT ---
The consequences of this bug are commonly observed by unwary as spurious
template instantation fails around std.string split and (previously) replace if
std.regex is imported.

This happens because std.string publicly and selectively imports a bunch of
functions from std.array and that brings about a pack of bad side effects.

(marked as critical as it cripples Phobos usage in a very unfriendly way)

The bug simplified:

//2 modules with unambigiuos template function
module m2;

void split(T)(T k)
    if(is(T : int)){}

//second one
module m;

void split(T)(T k)
    if(is(T : string))
{
}

//another one to call them
import m;
import m2: split; //removing : split makes it work

void main(){
    split("abc");
    split(123);
}

Output:
tryit.d(5): Error: template m2.split does not match any function template
declar
ation
tryit.d(5): Error: template m2.split(T) if (is(T : int)) cannot deduce template
function from argument types !()(string)

So, apparently, selectively imported symbol hides all others. 
Tested on DMD v2.060, was there since at least 2.056.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------

Reply via email to