Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

switch statement scope is broken #883

Open
brianush1 opened this issue Jan 5, 2023 · 0 comments
Open

switch statement scope is broken #883

brianush1 opened this issue Jan 5, 2023 · 0 comments

Comments

@brianush1
Copy link
Contributor

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:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant