www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 20868] New: DIP1000: scope delegate is implicitly convertible

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

          Issue ID: 20868
           Summary: DIP1000: scope delegate is implicitly convertible to
                    non-scope delegate
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: critical
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: andrej.mitrovich gmail.com

-----
void scoped (scope void delegate() dg)
{
    static void delegate()[] dgs;
    // dgs ~= dg;  // error

    nonScoped(dg);  // not an error???
}

void nonScoped (void delegate() dg)
{
    static void delegate()[] dgs;
    dgs ~= dg;
}

void main ()
{
    int x;
    scoped({x = 100;});
}
-----

$ dmd -dip1000 test.d
 
This should be a compile-time error. --
May 27