Skip to content
This repository was archived by the owner on Aug 6, 2023. It is now read-only.

Warn for duplicate case entry in switch #49

Open
tyra314 opened this issue Oct 19, 2018 · 0 comments
Open

Warn for duplicate case entry in switch #49

tyra314 opened this issue Oct 19, 2018 · 0 comments

Comments

@tyra314
Copy link

tyra314 commented Oct 19, 2018

When a switch contains a case entry with the same value twice, only one the first on will be executed. So a warning in a static case would be nice.

foo = 0;
switch (foo) do {
    case (0): {
        hint "You'll see this.";
    };
    case (0): {
        hint "You won't see this."
    };
};

And yes, I did basically that FeelsBadMan

*edit: Of course it won't only happen for literals

bar = 0;
foo = 0;
switch (foo) do {
    case (bar): {
        hint "You'll see this.";
    };
    case (bar): {
        hint "You won't see this."
    };
};

And the holy grail would be doing some static analysis to catch this:

bar = 0;
foo = 0;
switch (foo) do {
    case (0): {
        hint "You'll see this.";
    };
    case (bar): {
        hint "You won't see this."
    };
};
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant