Skip to content

Commit 495b637

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 eb3ddb8 commit 495b637

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

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

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

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

10011000
/** A conditional expression (`x if cond else y`). */
@@ -1754,6 +1753,11 @@ private module Input implements InputSig1, InputSig2 {
17541753
n2.isAdditional(assertStmt, assertThrowTag())
17551754
)
17561755
}
1756+
1757+
predicate matchAll(Ast::Case c) {
1758+
// A wildcard case (`case _:`) will match all values.
1759+
c.isWildcard()
1760+
}
17571761
}
17581762

17591763
import Public

0 commit comments

Comments
 (0)