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

ref discard produces nullability warning #73214

Open
stephentoub opened this issue Apr 24, 2024 · 2 comments
Open

ref discard produces nullability warning #73214

stephentoub opened this issue Apr 24, 2024 · 2 comments

Comments

@stephentoub
Copy link
Member

Version Used:
d8d7886

Steps to Reproduce:

var array = new object[1];
_ = ref array[0];

Diagnostic Id:
CS8619

Expected Behavior:
No warnings.

Actual Behavior:

warning CS8619: Nullability of reference types in value of type 'object' doesn't match target type 'object?'.
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead labels Apr 24, 2024
@jaredpar
Copy link
Member

Is that from an actual code pattern or just a behavior you observed? Trying to think of reason you'd want to discard a ref access and not coming up with one

@stephentoub
Copy link
Member Author

Just a behavior I observed as part of demonstrating to someone where covariance checks happen and being surprised when they didn't.

@jaredpar jaredpar added this to the Backlog milestone Apr 25, 2024
@jaredpar jaredpar added Bug New Language Feature - Nullable Reference Types Nullable Reference Types and removed untriaged Issues and PRs which have not yet been triaged by a lead labels Apr 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants