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

Nullability warning is missing on the lock statement #76597

Open
jnm2 opened this issue Jan 2, 2025 · 0 comments
Open

Nullability warning is missing on the lock statement #76597

jnm2 opened this issue Jan 2, 2025 · 0 comments
Labels
Area-Compilers Feature - Nullable Reference Types Nullable Reference Types help wanted The issue is "up for grabs" - add a comment if you are interested in working on it
Milestone

Comments

@jnm2
Copy link
Contributor

jnm2 commented Jan 2, 2025

Version Used: 17.13.0 Preview 2.1

There is no nullability warning for lock (null) { } or lock (maybeNullExpr) { }, even though a null at runtime throws ArgumentNullException.

Expected

A nullability warning such as:

  • CS8604 - Possible null reference argument for parameter.

    • More literal, similar to how await or foreach simply reflect the warning you'd get if you had manually called GetAwaiter()/GetEnumerator().
  • CS8602 - Dereference of a possibly null reference.

    • A step back, if calling expr in lock (expr) a "parameter" is leaking too much information about how lock is being lowered.

Or, one in the same vein as "CS8597 Thrown value may be null."

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead labels Jan 2, 2025
@jaredpar jaredpar added Feature - Nullable Reference Types Nullable Reference Types help wanted The issue is "up for grabs" - add a comment if you are interested in working on it and removed untriaged Issues and PRs which have not yet been triaged by a lead labels Jan 6, 2025
@jaredpar jaredpar added this to the Backlog milestone Jan 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Compilers Feature - Nullable Reference Types Nullable Reference Types help wanted The issue is "up for grabs" - add a comment if you are interested in working on it
Projects
None yet
Development

No branches or pull requests

2 participants