[Issue 17449] [DIP1000] crash due to covariant conversion of scope delegate to delegate

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Mar 11 21:33:32 UTC 2018


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

Walter Bright <bugzilla at digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|REOPENED                    |RESOLVED
         Resolution|---                         |WORKSFORME

--- Comment #7 from Walter Bright <bugzilla at digitalmars.com> ---
Fixing the code with @safe and @trusted:

---
module test;

@safe:
struct Event9834
{
  @safe:
    void delegate() dg;
    void set(void delegate() @safe h) pure { dg = h; }  // AV occurs
    void call() { dg(); }
}

void main()
{
    Event9834 ev;
    auto a = new class
    {
        Object o;
        this() @safe
        {
            o = new Object;
            ev.set(() @trusted { o.toString(); });
        }
    };
    ev.call();
}
---

and it compiles and runs without error, with or without -dip1000.

--


More information about the Digitalmars-d-bugs mailing list