www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 24466] New: `scope(exit)` should not be allowed in the main

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

          Issue ID: 24466
           Summary: `scope(exit)` should not be allowed in the main scope
                    of `noreturn` functions
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: accepts-invalid
          Severity: minor
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: b2.temp gmx.com

consider the following code

```d
noreturn v(int a)
{
    scope(exit) a++; // cant be executed    
    {
        scope(exit) a++; // this one is okay
    }
    assert(0);
}
```

There should be a sema error for the first scope guard as the defered
expression statement cannot be executed.

--
Mar 29