[Issue 20179] New: 'goto' skips over declaration triggered for unused variable

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Aug 29 03:11:02 UTC 2019


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

          Issue ID: 20179
           Summary: 'goto' skips over declaration triggered for unused
                    variable
           Product: D
           Version: D2
          Hardware: x86
                OS: Mac OS X
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: pro.mathias.lang at gmail.com

The following code:
```
string foo () { return null; }

void main ()
{
    if (auto str = foo())
    {
        assert(str.length);
    L1:
    }
    else
        goto L1;
}
```

Produces "oa.d(10): Error: goto skips declaration of variable oa.main.str at
oa.d(5)"
But the variable is not used after L1.

--


More information about the Digitalmars-d-bugs mailing list