www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 21545] New: [dip1000] cannot assign ref returning delegate to

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

          Issue ID: 21545
           Summary: [dip1000] cannot assign ref returning delegate to
                    variable with lower attributes
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: qs.il.paperinik gmail.com

Using -preview=dip1000, one cannot assign e.g. a pure delegate to a delegate
type variable without pure annotation:

void main()
{
    int i;
    alias DG = ref int delegate()  safe;
    DG dg = delegate ref()  safe => i;
}

This errors on the assignment of DG. Without the preview switch, it compiles.

--
Jan 13 2021