[Issue 24437] New: Optional arguments changing overload preference when compared to a varatic function
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Mar 14 22:15:47 UTC 2024
https://issues.dlang.org/show_bug.cgi?id=24437
Issue ID: 24437
Summary: Optional arguments changing overload preference when
compared to a varatic function
Product: D
Version: D2
Hardware: x86_64
OS: Linux
Status: NEW
Severity: enhancement
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: crazymonkyyy at gmail.com
```d
import std;
auto notfoo(T)(T[] args...){
"wrong function 1".writeln;
}
auto notfoo(T,S)(T[S] args){
"right function 1".writeln;
}
auto notfoo2(T)(T[] args...){
"wrong function 2".writeln;
}
auto notfoo2(T,S)(T[S] args,int i=1000){
"right function 2".writeln;
}
void main(){
[1:'a',2:'b',3:'c'].notfoo;
"---".writeln;
[1:'a',2:'b',3:'c'].notfoo2;
}
```
right function 1
---
wrong function 2
https://dlang.org/spec/function.html#function-overloading
> 7. A function with a variadic argument is considered less specialized than a function without.
--
More information about the Digitalmars-d-bugs
mailing list