Fix constant cases relating to enum types

This commit is contained in:
Chris Smowton
2023-10-27 12:46:47 +01:00
parent b21aaa75bc
commit 30c5885966

View File

@@ -486,7 +486,11 @@ class SwitchCase extends Stmt, @case {
/** A constant `case` of a switch statement. */
class ConstCase extends SwitchCase {
ConstCase() { exists(Literal e | e.getParent() = this and e.getIndex() >= 0) }
ConstCase() {
exists(Expr e |
e.getParent() = this and e.getIndex() >= 0 and not e instanceof LocalVariableDeclExpr
)
}
/** Gets the `case` constant at index 0. */
Expr getValue() { result.isNthChildOf(this, 0) }