[Issue 22153] New: Non-void arrays do not match`inout void[]` arguments in implicit function template instantiation (IFTI)

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Jul 28 14:50:16 UTC 2021


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

          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 at puremagic.com
          Reporter: n8sh.secondary at hotmail.com

Example:

---
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)`

--


More information about the Digitalmars-d-bugs mailing list