Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SE: Learn NotNull from ??= for nullable types #7322

Closed
Tim-Pohlmann opened this issue Jun 1, 2023 · 0 comments · Fixed by #7346
Closed

SE: Learn NotNull from ??= for nullable types #7322

Tim-Pohlmann opened this issue Jun 1, 2023 · 0 comments · Fixed by #7346
Assignees
Labels
Area: C# C# rules related issues. Area: CFG/SE CFG and SE related issues.
Milestone

Comments

@Tim-Pohlmann
Copy link
Contributor

arg ??= 0;
if(arg is null)
{
  // This should be unreachable
}

??= is being translated to a check of .HasValue. Currently, the engine cannot detect the above case, because it does not learn NotNull on the arg.HasValue branch.
See original discussion:
#7312 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: C# C# rules related issues. Area: CFG/SE CFG and SE related issues.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants