Bug 7431 – overload resolution should be more fine-grained

Status
REOPENED
Severity
enhancement
Priority
P4
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-02-03T14:57:21Z
Last change time
2024-12-13T17:58:16Z
Assigned to
No Owner
Creator
timon.gehr
Moved to GitHub: dmd#18410 →

Comments

Comment #0 by timon.gehr — 2012-02-03T14:57:21Z
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 by maxhaton — 2021-01-24T07:00:41Z
Language change
Comment #2 by robert.schadek — 2024-12-13T17:58:16Z
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