www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 23271] New: `goto` skips declaration of variable

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

          Issue ID: 23271
           Summary: `goto` skips declaration of variable
                    `bugred.A.test.__appendtmp4`
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: regression
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: destructionator gmail.com

dmd master broke this code:

---
class A {
        private static A[] active;
        private void test() {
                foreach(a; active)
                        if(a is this)
                                goto label;
                active ~= this;
                label:
                return;
        }
}
---

bugred.d(6): Error: `goto` skips declaration of variable
`bugred.A.test.__appendtmp4` at bugred.d(7)

--
Jul 25 2022