Skip to content

C#: Prepare for pattern flow. - #22711

Merged
michaelnebel merged 5 commits into
github:mainfrom
michaelnebel:csharp/prepareforpatternflow
Oct 2, 2026
Merged

michaelnebel merged 5 commits into
github:mainfrom
michaelnebel:csharp/prepareforpatternflow

Conversation

@michaelnebel

@michaelnebel michaelnebel commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

In this PR we re-factor parts of the C# specific data flow and assignable definition.
It turns out that the existing logic contains some unwanted flow steps.

  • There was flow from the matched expression in is expressions and switch/case statements to any sub-tuple pattern. However, there should only be a flow step to the immediate top-level pattern in match - flow to sub patterns should be handled as read steps.
  • Local variable assignable definitions also contained sub-pattern variable declarations. Instead the PatternDefinition Assignable definition has been modified to include all sub pattern variable declarations. This will be needed in a subsequent PR.

DCA looks good.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🔵 Needs a closer look

It changes foundational C# assignable, SSA, and local data-flow semantics that warrant final human validation.

Review effort: Balanced
Findings: None

What changed in this PR

Refactors C# pattern definitions and tuple-pattern flow to distinguish top-level matches from sub-pattern reads.

Changes:

  • Adds TuplePatternExpr and limits direct flow to top-level tuple patterns.
  • Represents nested pattern declarations as PatternDefinition.
  • Updates dependent analyses and generated test expectations.
File Description
Tuples.cs Normalizes the final line.
tuples/​PrintAst.expected Updates tuple-pattern AST expectations.
DataFlowStep.expected Removes unwanted pattern-flow edges.
csharp8/​PrintAst.expected Updates tuple-pattern classifications.
DeadStoreOfLocal.ql Retains top-level pattern semantics.
Expr.qll Adds TuplePatternExpr.
Nullness.qll Restricts non-null definitions to top-level patterns.
DataFlowPrivate.qll Refines tuple-pattern flow and read steps.
Assignable.qll Extends pattern definitions to nested declarations.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@michaelnebel michaelnebel added the no-change-note-required This PR does not need a change note label Oct 1, 2026
@michaelnebel
michaelnebel requested a review from hvitved October 1, 2026 07:33
@michaelnebel
michaelnebel marked this pull request as ready for review October 1, 2026 07:33
@michaelnebel
michaelnebel requested a review from a team as a code owner October 1, 2026 07:33
@michaelnebel
michaelnebel merged commit 4f40d24 into github:main Oct 2, 2026
25 checks passed
@michaelnebel
michaelnebel deleted the csharp/prepareforpatternflow branch October 2, 2026 08:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C# no-change-note-required This PR does not need a change note

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants