www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 22153] New: Non-void arrays do not match`inout void[]`


          Issue ID: 22153
           Summary: Non-void arrays do not match`inout void[]` arguments
                    in implicit function template instantiation (IFTI)
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: n8sh.secondary hotmail.com


size_t bytesUsed1()(const void[] array) { return array.length; }
size_t bytesUsed2()(inout void[] array) { return array.length; }

void main(string[] args)
    // Works when required arg is const instead of inout.
    auto a = args.bytesUsed1;

    // Works when explicitly instantiating template.
    auto b = args.bytesUsed2!();

    // Works when manually converting array to void[].
    auto c = (cast(void[]) args).bytesUsed2;

    // Following line fails to compile:
    auto d = args.bytesUsed2;

app.d(16): Error: template `app.bytesUsed2` cannot deduce function from
argument types `!()(string[])`, candidates are:
app.d(2):        `bytesUsed2()(inout void[] array)`

Jul 28 2021