www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 18858] New: switch 'skips declaration' test only checks last

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

          Issue ID: 18858
           Summary: switch 'skips declaration' test only checks last
                    declaration
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: bugzilla digitalmars.com

Consider:

  int test(int n)
  {
    final switch(n)
    {
        enum e = 6;
        int z = 5; // Error: switch skips declaration of variable test.z

        case 1:
            int y = 2;
            return y;
    }
  }

Good. Now reverse the enum e and int z statements, and no error will be
generated.

--
May 14 2018