www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 23159] New: [betterC] scope(failure) use in betterC gives

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

          Issue ID: 23159
           Summary: [betterC] scope(failure) use in betterC gives
                    confusing error
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: jack jackstouffer.com

```
void main()
{
    scope(failure)
    {
        int a;
    }
    int b;
}
```

Gives

```
$ dmd -betterC main.d
Error: Cannot use try-catch statements with -betterC
```

Two problems here. One, there's no line number. Two, this does not give any
indication to the user about the true cause of this error. Thankfully I knew
what to look for because I knew that scope(failure) was lowered to a try catch
from a dconf talk.

Really, scope(success)/scope(failure) has no business being in betterC code and
should get its own custom error message.

--
Jun 04 2022