www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 7431] New: overload-resolution should be more fine-grained

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

           Summary: overload-resolution should be more fine-grained
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: timon.gehr gmx.ch
            Blocks: 7355



immutable(int)[] bar(immutable(int)[] x){return x;}
int[] bar(int[] x){return x;}

immutable(int)[] foo(immutable(int)[] x, float f){return x;}
int[] foo(int[] x, float f){return x;}

void main(){
    bar([1,2,3]);  // fine, second version is chosen
    foo([1,2,3],4);// currently an error
}

Both foos are a convert match, and neither one is deduced more specialized by
the current rules. I propose to add the following intuitive rule to improve the
programmer-conceived language consistency:

"If a parameter type better matches the argument type than another one, it is
considered to be more specialized."

This will make the foo invocation call the second overload, consistent with how
bar is handled.

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