Skip to content

Commit c7fda0c

Browse files
committed
python:
A wildcard case (`case _:`) should not be considered default as the CFG library will then order it last. Instead it is a `matchAll`
1 parent 1ee9158 commit c7fda0c

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

python/ql/lib/semmle/python/controlflow/internal/AstNodeImpl.qll

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -993,10 +993,7 @@ module Ast implements AstSig<Py::Location> {
993993
}
994994
}
995995

996-
/** A wildcard case (`case _:`). */
997-
class DefaultCase extends Case {
998-
DefaultCase() { this.isWildcard() }
999-
}
996+
class DefaultCase extends Case { }
1000997

1001998
/** A conditional expression (`x if cond else y`). */
1002999
class ConditionalExpr extends Expr {
@@ -1753,6 +1750,9 @@ private module Input implements InputSig1, InputSig2 {
17531750
n2.isAdditional(assertStmt, assertThrowTag())
17541751
)
17551752
}
1753+
1754+
/** A wildcard case (`case _:`) will match all values. */
1755+
predicate matchAll(Ast::Case c) { c.isWildcard() }
17561756
}
17571757

17581758
import Public

0 commit comments

Comments
 (0)