www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 20506] New: [DIP1000] scope variable cannot be thrown


          Issue ID: 20506
           Summary: [DIP1000] scope variable cannot be thrown
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: safe
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: pro.mathias.lang gmail.com


void main ()  safe  nogc nothrow
    scope exc = new Exception("Baguette");
    try {
        throw exc;
    } catch (Exception e) {
        assert(e is exc);

bug.d(5): Error: scope variable exc may not be thrown

The code is obviously ` safe`: While a scope variable is thrown, the function
itself is nothrow, meaning the function cannot escape the scope of this
function (even if passed down to another function).

Jan 15 2020