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 mismatch in non-ref foreach cannot be suppressed #75430

Open
jjonescz opened this issue Oct 8, 2024 · 1 comment · May be fixed by #75432
Open

Nullability mismatch in non-ref foreach cannot be suppressed #75430

jjonescz opened this issue Oct 8, 2024 · 1 comment · May be fixed by #75432

Comments

@jjonescz
Copy link
Member

jjonescz commented Oct 8, 2024

Originally posted by @TessenR in #73928 (comment)

Is it expected that now you can suppress nullability mismatch for foreach with ref variables but not for foreach with regular variables?

It looks like the following test is supposed to cover that scenario, but it's missing the actual nullability mismatch because the parameter of the test method is object[] instead of object?[]

image

9941c1f#diff-14fe026e6093e9522c01e6c377b26554dd6b663214884198dcc244f370548fa1R90883

The following code right now does have a warning and it cannot be suppressed:

void M2(object?[] a) { foreach (object item in a!) { } }
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead labels Oct 8, 2024
@jjonescz jjonescz self-assigned this Oct 8, 2024
@jaredpar jaredpar added this to the 17.13 milestone Oct 8, 2024
@jaredpar jaredpar added Bug and removed untriaged Issues and PRs which have not yet been triaged by a lead labels Oct 8, 2024
@alrz
Copy link
Contributor

alrz commented Oct 8, 2024

This looks very much like #38586

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

Successfully merging a pull request may close this issue.

3 participants