[Issue 14353] SDC test0104.d fails under DMD

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Sat Mar 28 09:46:35 PDT 2015


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

ag0aep6g at gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ag0aep6g at gmail.com

--- Comment #1 from ag0aep6g at gmail.com ---
I think this is invalid. `t.add` and `s.add` are parentheses-less calls. So the
error about T.add not being callable "using argument types ()" is correct. To
get a delegate, add '&':

struct S {
    int i;
    T t;

    auto add(int a) {
        t.i = a + i;
        return &t.add; /* ! */
    }
}

struct T {
    int i;
    int add(int a) {
        return i + a;
    }
}

int main() {
    S s;
    s.i = s.t.i = 1;
    auto dg1 = &s.add; /* ! */
    auto dg2 = dg1(34);
    return dg2(7);
}

--


More information about the Digitalmars-d-bugs mailing list