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

          Issue ID: 16467
           Summary: templated function default argument take into account
                    when not needed
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected]

T identity(T)(T t = 0)
{
    return t;
}

void main()
{
    int i = identity(); // as expected

    string s = identity("hello");  // error: cannot implictly converto (0)
                                   // of type int to string
}

I would expect the default value to be completely discarded when the user
supplies a value.

--

Reply via email to