struct A { void method() pure @safe nothrow @nogc { } } void test(scope void delegate() del) @safe { } void main() @safe { A a; // OK: void delegate() del = &a.method; /* onlineapp.d(19): Error: function onlineapp.test(scope void delegate() del) is not callable using argument types (void delegate() pure nothrow @nogc @safe) onlineapp.d(19): cannot pass argument &a.method of type void delegate() pure nothrow @nogc @safe to parameter scope void delegate() del */ test(&a.method); } The above code works fine - as, I believe, it should - unless I compile with -preview=dip1000 . This issue breaks some of my toString() implementations, so a fix would be appreciated...
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.
This is working in master.