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

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Aug 1 14:21:42 UTC 2018


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

anonymous4 <dfj1esp02 at sneakemail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Hardware|x86                         |All
                 OS|Mac OS X                    |All

--- Comment #2 from anonymous4 <dfj1esp02 at sneakemail.com> ---
struct W(T) {
    this(inout(T) val) inout {}
}

auto wrap0(T)(inout(T) t) {
    return inout W!T(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
}

The code has a mistake: it should be return inout W!T(t); - the constructor has
an inout parameter, but the error is the same. Looks more like a bug than an
enhancement.

--


More information about the Digitalmars-d-bugs mailing list