[Issue 24534] Having a label on a declaration makes it possible to skip it with goto

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri May 3 21:09:06 UTC 2024


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

Richard Cattermole <alphaglosined at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P1                          |P3
                 CC|                            |alphaglosined at gmail.com
           Severity|normal                      |enhancement

--- Comment #2 from Richard Cattermole <alphaglosined at gmail.com> ---
After thinking about this, it's intentional.

This allows you to have multiple blocks at the end of your function that handle
things like success versus error.

It is very C style, and is used in dmd.

The solution of course would be to create a new scope so it doesn't bleed
between the labels.

```d
goto Lerror;

Lsuccess:
{

}

Lerror:
{

}
```

If this is fixed, it's going to need a very long deprecation.

Or we could kill off this logic entirely and have type state analysis proper
which works on a per-variable basis rather than a coarse reverse search which
it is currently.

--


More information about the Digitalmars-d-bugs mailing list