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