March 07, 2023
https://issues.dlang.org/show_bug.cgi?id=23762

          Issue ID: 23762
           Summary: Missing switch case fallthrough error when generating
                    cases with `static foreach`
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: accepts-invalid
          Severity: normal
          Priority: P2
         Component: dmd
          Assignee: nobody@puremagic.com
          Reporter: timon.gehr@gmx.ch

DMD 2.102.2:

The following code is correctly rejected due to switch case fallthrough:

---
import std.stdio;
void main(){
    int i=2;
    switch(i){
        default: writeln("default"); break;
        case 0: writeln(0);
        case 1: writeln(1);
        case 2: writeln(2);
        case 3: writeln(3);
        case 4: writeln(4);
    }
}
---

However, the switch case fallthrough errors are not emitted when generating the cases with `static foreach`:

---
import std.stdio;
void main(){
    int i=2;
    switch(i){
        default: writeln("default"); break;
        static foreach(j;0..5)
        case j: writeln(j);
    }
}
---

--