www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 22119] New: [Functions] Function Overloading clarity for

https://issues.dlang.org/show_bug.cgi?id=22119

          Issue ID: 22119
           Summary: [Functions] Function Overloading clarity for int[] and
                    strings
           Product: D
           Version: D2
          Hardware: All
               URL: http://dlang.org/
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P3
         Component: dlang.org
          Assignee: nobody puremagic.com
          Reporter: crazymonkyyy gmail.com

Created attachment 1824
  --> https://issues.dlang.org/attachment.cgi?id=1824&action=edit
code with confususion, line 50

import std;
struct bar{
        int i;
}
struct foo{
        bar i; alias i this;
}
void foobar(bar[] yo){
//void foobar(T:bar[])(T yo){
        "bar[]".writeln;
}
void foobar(T:foo)(T[3] t){
        "foo[3]".writeln;}
unittest{
        foobar([foo(),foo(),foo()]);
}

---

I would suggest throwing in a note that says something like "int[3] matches to
string before T[3] this can be fixed by redefining string function to
'(T:string)(T s)'"

--
Jul 12