Skip to content

Visit left operand conversion in a fast path of nullable analysis - #85115

Merged
jjonescz merged 2 commits into
dotnet:mainfrom
jjonescz:84642-BoundConversionInMap
Sep 4, 2026
Merged

Visit left operand conversion in a fast path of nullable analysis#85115
jjonescz merged 2 commits into
dotnet:mainfrom
jjonescz:84642-BoundConversionInMap

Conversation

@jjonescz

@jjonescz jjonescz commented Sep 1, 2026

Copy link
Copy Markdown
Member

Fixes #84642.

In VisitBinaryOperatorChildren, the conversion from the LHS is removed but then in the code path going through learnFromConditionalAccessOrBoolConstant, the removed conversion wasn't visited, failing the assert.

Microsoft Reviewers: Open in CodeFlow

@jjonescz
jjonescz requested a balanced review from Copilot September 1, 2026 08:18
@azure-pipelines

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

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.

🔵 Needs a closer look

Pull request overview

Fixes a nullable-analysis fast path that skipped the left operand’s implicit conversion, triggering debug verification failures.

Changes:

  • Visits the stripped left conversion before evaluating the right operand.
  • Adds regression coverage for default != true.
  • No code issues identified; CI remains in progress.
File summaries
File Description
NullableWalker.cs Records the omitted conversion in nullable analysis.
NullableReferenceTypesTests.cs Adds the issue regression test.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 0
  • Review effort level: Balanced

@jjonescz
jjonescz force-pushed the 84642-BoundConversionInMap branch from dce3074 to 03e7af9 Compare September 1, 2026 12:51
@jjonescz
jjonescz marked this pull request as ready for review September 1, 2026 16:02
@jjonescz
jjonescz requested a review from a team as a code owner September 1, 2026 16:02
Copilot AI review requested due to automatic review settings September 1, 2026 16:02
@azure-pipelines

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

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.

🟢 Approval recommended

Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

if (binary.Left is BoundConversion leftConversionNode && leftConversionNode != leftOperand)
{
Debug.Assert(leftConversionNode.Type is not null);
VisitConversion(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is this double-visiting the operand itself? Should we instead just be calling SetAnalyzedNullability?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

No, this calls the private VisitConversion overload which assumes the operand was already visited, it does not visit it again. I think a double visit would also fail some debug assert.

I think calling VisitConversion is correct. It's what other code paths of VisitBinaryOperatorChildren eventually call too - see line 5670.

// The left operand was visited without its stripped conversion.
if (binary.Left is BoundConversion leftConversionNode && leftConversionNode != leftOperand)
{
Debug.Assert(leftConversionNode.Type is not null);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: It looks like the constructor of BoundConversion already asserts this

Copilot AI review requested due to automatic review settings September 3, 2026 07:37

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.

🔵 Needs a closer look

The fix appears correct, but it modifies sensitive nullable-flow logic and CI for the latest commit remains in progress.

Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

@jjonescz
jjonescz requested a review from RikkiGibson September 3, 2026 10:55
@jjonescz
jjonescz merged commit 766a236 into dotnet:main Sep 4, 2026
22 checks passed
@jjonescz
jjonescz deleted the 84642-BoundConversionInMap branch September 4, 2026 10:54
@dotnet-policy-service dotnet-policy-service Bot added this to the Next milestone Sep 4, 2026
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.

Debug Build fails with System.InvalidOperationException: Did not find Microsoft.CodeAnalysis.CSharp.BoundConversion default in the map.

4 participants