[Issue 20116] Wrong delegate type when taking address of inout member function

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Aug 15 17:21:31 UTC 2019


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

Simen Kjaeraas <simen.kjaras at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |simen.kjaras at gmail.com
            Summary|Cannot return inout return  |Wrong delegate type when
                   |value from delegate         |taking address of inout
                   |                            |member function

--- Comment #2 from Simen Kjaeraas <simen.kjaras at gmail.com> ---
I've updated the description to give a better description of what's actually
wrong here.

The actual issue is what typeof(&c.arr) returns - it needs to reflect the
constancy of c - inout makes no sense on the context of a delegate. IOW, this:

class C {
    int[] _arr;
    auto fun() inout { return _arr; }
}

static assert(is(typeof(&(new           C).fun) ==           int[] 
delegate()));
static assert(is(typeof(&(new const     C).fun) == const    (int[])
delegate()));
static assert(is(typeof(&(new immutable C).fun) == immutable(int[])
delegate()));

should compile.

--


More information about the Digitalmars-d-bugs mailing list