Skip to content

Conversation

@tausbn
Copy link
Contributor

@tausbn tausbn commented Feb 11, 2025

Extends the mechanism introduced in #18030 to behave the same for all MatchLiteralPatterns, not just the ones that happen to be the constant True or False.

Extends the mechanism introduced in
#18030
to behave the same for _all_ `MatchLiteralPattern`s, not just the ones
that happen to be the constant `True` or `False`.

Co-authored-by: yoff <yoff@github.com>
Co-authored-by: yoff <yoff@github.com>
@tausbn tausbn marked this pull request as ready for review February 11, 2025 14:21
Copilot AI review requested due to automatic review settings February 11, 2025 14:21
@tausbn tausbn requested a review from a team as a code owner February 11, 2025 14:21
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Overview

This pull request extends the mechanism for pruning to ensure that no MatchLiteralPattern is ever pruned, avoiding the risk of misidentifying reachable code.

  • The change notes have been updated to reflect the new behavior.
  • The conditional check in the pruner for boolean literal patterns has been removed so that all MatchLiteralPatterns are processed uniformly.

Changes

File Description
python/ql/lib/change-notes/2025-02-11-fix-match-literal-pruning.md Added notes to clarify that no MatchLiteralPattern is pruned
python/extractor/semmle/python/passes/pruner.py Removed conditional pruning for boolean MatchLiteralPatterns to apply the fix universally

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

Tip: If you use Visual Studio Code, you can request a review from Copilot before you push from the "Source Control" tab. Learn more

Co-authored-by: Aditya Sharad <6874315+adityasharad@users.noreply.github.com>
@tausbn tausbn added the Awaiting evaluation Do not merge yet, this PR is waiting for an evaluation to finish label Mar 4, 2025
@tausbn tausbn removed the Awaiting evaluation Do not merge yet, this PR is waiting for an evaluation to finish label Mar 11, 2025
Copy link
Contributor

@yoff yoff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@yoff yoff merged commit 10a9b78 into main Mar 12, 2025
13 checks passed
@yoff yoff deleted the tausbn/python-fix-match-pruning-logic branch March 12, 2025 19:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants