[Issue 19126] New: Compiler removes inout on templated parameter and then complains it's not there

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Jul 29 17:44:58 UTC 2018


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

          Issue ID: 19126
           Summary: Compiler removes inout on templated parameter and then
                    complains it's not there
           Product: D
           Version: D2
          Hardware: x86
                OS: Mac OS X
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: ali.akhtarzada at gmail.com

struct W(T) {
    this(U : T)(auto ref inout(U) val) inout {}
}

auto wrap0(T)(auto ref inout(T) t) {
    return inout W!T();
}

auto wrap1(T)(auto ref inout(T) t) {
    return t;
}

void main() {
    wrap0!int(3); // ok
    wrap0!(const int)(3); // ok
    wrap0!(immutable int)(3); // Error: inout on return means inout must be on
a parameter

    wrap1!int(3); // ok
    wrap1!(const int)(3); // ok
    wrap1!(immutable int)(3); // ok
}

--


More information about the Digitalmars-d-bugs mailing list