www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 18295] New: [Scope][dip1000] `scope class` check too

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

          Issue ID: 18295
           Summary: [Scope][dip1000] `scope class` check too conservative
                    under -dip1000
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: slavo5150 yahoo.com

In practice, the following two examples are no different:

Example 1: Compile with -dip1000
--------------------------------
scope class C { int i; }    // Notice the use of `scope` here

C increment(C c)            // Error: functions cannot return scope C
{
    c.i++;
    return c;
}

void main()
{
    scope C c = new C();
    c.increment();
}

Example 2: Compile with -dip1000
--------------------------------
class C { int i; }           // Notice the absence of `scope` here

C increment(C c)             // OK: no error
{
    c.i++;
    return c;
}

void main()
{
    scope C c = new C();
    c.increment();
}

So, I argue that with the introduction of the -dip1000 compiler switch it is no
longer necessary conservatively check the function declaration for `scope
class`es.  Rather a `scope class` should simply require variable instantiations
to be attributed with `scope`, and let -dip1000 do the rest.

--
Jan 24