D-Scanner icon indicating copy to clipboard operation
D-Scanner copied to clipboard

switch statement scope is broken

Open brianush1 opened this issue 3 years ago • 0 comments

import std.stdio;

void main() {
    int x = 5;
    switch (x) {
    case 3:
        int y = x + 2;
        writeln(y);
        break;
    default:
        int y = x + 3;
        writeln(y);
        break;
    }
}

gives Variable "y" has the same name as a variable defined on line 7. on line 11 even though that's perfectly fine

the bug goes away if default: is replaced with another case whatever:

brianush1 avatar Jan 05 '23 03:01 brianush1