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

Walter Bright <[email protected]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |[email protected]

--- Comment #1 from Walter Bright <[email protected]> ---
The following will work:

  struct A {
    int* p;
    void method() scope pure @safe nothrow @nogc { }
  }

  void test(scope void delegate() del) @safe { }

  void main() @safe {
    A a;
    test(&a.method); 
  }

Note the two additions:

1. `scope` to method(), which says that the method won't escape `this.p`
2. `int* p;` because otherwise the `scope` added will be ignored

A possible fix to the compiler would be to have the address of a method be
implicitly marked `scope` if none of the fields have any indirections.

--

Reply via email to