http://d.puremagic.com/issues/show_bug.cgi?id=6823

           Summary: Shared Delegates Should Implicitly Cast to Nonshared
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: major
          Priority: P2
         Component: DMD
        AssignedTo: nob...@puremagic.com
        ReportedBy: debio...@gmail.com


--- Comment #0 from Andrew Wiley <debio...@gmail.com> 2011-10-17 23:58:06 PDT 
---
Code Example:
synchronized class Thing {
        void doSomeWork(void delegate() work) {
                work();
        }
        void work() {}
}

void main() {
        auto th = new Thing();
        th.doSomeWork(&th.work);
}

This example won't compile because the type of `&th.work` is `void delegate()
shared`, which will not implicitly convert to `void delegate()`.
This type is probably correct - it's safe to share that delegate between
threads, but since it's also safe to NOT share that delegate between threads,
the delegate should implicitly cast to non-shared.

This is a large problem for code using shared data because `void delegate()
shared` does not parse as a type.

The current workaround is to insert a cast to `void delegate()` at the call
site.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------

Reply via email to