Skip to content

Preserve directly deconstructed tuple values in analyzer flow - #134469

Draft
jtschuster wants to merge 1 commit into
tuple-localvalue-latticefrom
tuple-structured-deconstruction
Draft

jtschuster wants to merge 1 commit into
tuple-localvalue-latticefrom
tuple-structured-deconstruction

Conversation

@jtschuster

@jtschuster jtschuster commented Sep 22, 2026 •

Copy link
Copy Markdown
Member

Summary

In the analyzer, we see ITupleOperations that could be lowered to ValueTuple construction and destruction, or lowered to assignments to local variables -- but there is no way to know for sure. However, the basic (and relatively common) case of (a, b) = (b, a) should be supported. This requires us to model a Tuple value in dataflow. In the current implementation, we can model it in Deconstruction evaluation, but it's not a first-class concept in the dataflow visitor. This PR stack makes the concept of a Tuple of TValue a first-class concept.

ITupleOperations are treated as Top in the lattice for all cases except for when it is the outer operation on a DeconstructionOperation (i.e. an expression in the form of (a, b) = (b, a)). If the TupleOperation appears elsewhere in the deconstruction (for example, within a ternary that is deconstructed (a, b) = c ? (x, y) : (b, a)), we make no assumption about whether or not a ValueTuple is created.

This PR preserves recursively evaluated direct tuple deconstruction sources before target assignments. Ordinary tuple flow still evaluates elements for effects without guessing whether syntax lowers to ValueTuple fields.

Validation

  • Analyzer DataFlow: 85 passed, 2 skipped.
  • ILLink DataFlow0: 42 passed; DataFlow1: 41 passed.
  • NativeAOT shared ConstructedTypesDataFlow and DeconstructFieldTarget: 2 passed.

Note

This PR was generated with GitHub Copilot assistance.


Stack created with GitHub Stacks CLI • Give Feedback 💬

@jtschuster
jtschuster added this pull request to stack #134470 September 22, 2026 22:14
@dotnet-policy-service dotnet-policy-service Bot added the linkable-framework Issues associated with delivering a linker friendly framework label Sep 22, 2026
@github-actions github-actions Bot added the area-Tools-ILLink .NET linker development as well as trimming analyzers label Sep 22, 2026
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).
13 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @agocke, @dotnet/illink
See info in area-owners.md if you want to be subscribed.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@jtschuster
jtschuster force-pushed the tuple-structured-deconstruction branch from 84e0c70 to 33ef7aa Compare September 22, 2026 23:28

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-Tools-ILLink .NET linker development as well as trimming analyzers linkable-framework Issues associated with delivering a linker friendly framework

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

1 participant