sqf
sqf copied to clipboard
Warn for duplicate case entry in switch
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."
};
};