D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 7431 - overload resolution should be more fine-grained
Summary: overload resolution should be more fine-grained
Status: REOPENED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P4 enhancement
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-02-03 14:57 UTC by timon.gehr
Modified: 2024-12-13 17:58 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description timon.gehr 2012-02-03 14:57:21 UTC
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.
Comment 1 mhh 2021-01-24 07:00:41 UTC
Language change
Comment 2 dlangBugzillaToGithub 2024-12-13 17:58:16 UTC
THIS ISSUE HAS BEEN MOVED TO GITHUB

https://github.com/dlang/dmd/issues/18410

DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB