Summary: selective import breaks normal overload resolution
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: critical
          Priority: P2
         Component: DMD

--- Comment #0 from Dmitry Olshansky <> 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(){

tryit.d(5): Error: template m2.split does not match any function template
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:
------- You are receiving this mail because: -------

Reply via email to