[Issue 24466] New: `scope(exit)` should not be allowed in the main scope of `noreturn` functions

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Mar 29 07:08:11 UTC 2024


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 at puremagic.com
          Reporter: b2.temp at 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.

--


More information about the Digitalmars-d-bugs mailing list