Skip to content

Commit c6cd4b6

Browse files
committed
Shared: Account for default cases when handling exhaustiveness
1 parent d383b86 commit c6cd4b6

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

‎shared/controlflow/codeql/controlflow/ControlFlowGraph.qll‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -859,6 +859,10 @@ module Make0<LocationSig Location, AstSig<Location> Ast> {
859859
or
860860
exists(Switch switch, int last |
861861
Input1::isExhaustive(switch) and
862+
// Default cases are always considered last in control flow order, so
863+
// exhaustiveness does not apply to the last case if a default case
864+
// exists.
865+
not switch.getCase(last) instanceof DefaultCase and
862866
switch.getCase(last) = c and
863867
not exists(switch.getCase(last + 1))
864868
)

0 commit comments

Comments
 (0)