Skip to content

Fix false CS8619 for ref notnull discard assignment (fixes #82919)#83057

Open
sabaka-chabaka wants to merge 6 commits intodotnet:mainfrom
sabaka-chabaka:fix-nullability-discard-82919
Open

Fix false CS8619 for ref notnull discard assignment (fixes #82919)#83057
sabaka-chabaka wants to merge 6 commits intodotnet:mainfrom
sabaka-chabaka:fix-nullability-discard-82919

Conversation

@sabaka-chabaka
Copy link
Copy Markdown

@sabaka-chabaka sabaka-chabaka commented Apr 3, 2026

Summary

This PR fixes a false positive CS8619 warning when performing a ref discard assignment of a notnull type.

Details

In NullableWalker.VisitDiscardExpression, the code was forcing NullableAnnotation.Annotated if node.IsInferred was true. This caused notnull types to be treated as nullable during discard, leading to incorrect mismatch warnings. Changed to use node.NullableAnnotation directly from the bound node.

Fixes #82919

Microsoft Reviewers: Open in CodeFlow

@sabaka-chabaka sabaka-chabaka requested a review from a team as a code owner April 3, 2026 20:57
@dotnet-policy-service dotnet-policy-service bot added the Community The pull request was submitted by a contributor who is not a Microsoft employee. label Apr 3, 2026
@sabaka-chabaka
Copy link
Copy Markdown
Author

@dotnet-policy-service agree

@azure-pipelines
Copy link
Copy Markdown

Commenter does not have sufficient privileges for PR 83057 in repo dotnet/roslyn

@sabaka-chabaka
Copy link
Copy Markdown
Author

sabaka-chabaka commented Apr 4, 2026

The pipelines is bugged i think.

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

Labels

Area-Compilers Community The pull request was submitted by a contributor who is not a Microsoft employee.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant