[Issue 7431] New: overload-resolution should be more fine-grained
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Feb 3 14:57:22 PST 2012
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 at puremagic.com
ReportedBy: timon.gehr at gmx.ch
Blocks: 7355
--- Comment #0 from timon.gehr at gmx.ch 2012-02-03 14:57:21 PST ---
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: -------
More information about the Digitalmars-d-bugs
mailing list