www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 14797] New: template with inout parameter `foo(String:


          Issue ID: 14797
           Summary: template with inout parameter `foo(String:
                    inout(CharT)[], CharT)` should be implicitly
                    instanciated as foo!(char[], char)
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: ttanjo gmail.com

In the following code, foo(String: inout(CharT)[], CharT) should be implicitly
instanciated as foo!(char[], char) but it does not.

I checked it doesn't work with dmd trunk v2.068-devel-4bc3d3d on Mac OSX.

inout(dchar)[] foo(String: inout(CharT)[], CharT)(String str)
    return typeof(return).init;

void main()
    char[] str = "str".dup;

    auto b = foo!(inout(char)[], char)(str); // it works

    auto a = foo(str); // it doesn't work but it should

error.d(10): Error: template error.foo cannot deduce function from argument
types !()(char[]), candidates are:
error.d(1):        error.foo(String : inout(CharT)[], CharT)(String str)

P.S. Its severity may be `enhancement` instead of normal.

Jul 12 2015