www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 15307] New: Delegate with immutable and shared context do not

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

          Issue ID: 15307
           Summary: Delegate with immutable and shared context do not
                    convert to one another
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: jakobovrum gmail.com

void main()
{
    immutable i = 42;
    auto dg = delegate void() immutable { auto inner = i; };
    void delegate() shared dg2 = dg; // Fails
}

---

This might be a useful conversion to have for non-templated functions like
std.concurrency.Scheduler.spawn (which currently does not enforce
shared/immutable context).

--
Nov 09 2015