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

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

void main() {
        auto th = new Thing();

This example won't compile because the type of `&` 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

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to