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

Report warning using foreach with a nullable value #23493

Closed
cston opened this issue Nov 30, 2017 · 2 comments
Closed

Report warning using foreach with a nullable value #23493

cston opened this issue Nov 30, 2017 · 2 comments
Assignees
Milestone

Comments

@cston
Copy link
Member

cston commented Nov 30, 2017

A warning should be reported using foreach with a nullable value.

class C
{
    static void F(object[]? args)
    {
        foreach (var o in args) // warn
        {
        }
    }
}
@jcouv jcouv added this to the 16.0 milestone Dec 15, 2017
@jcouv
Copy link
Member

jcouv commented May 14, 2018

Also, we need to check the nullability of values returned by yield:

using System.Collections.Generic;
public class C 
{
    public IEnumerable<(string, string)> M() 
    {
       yield return (null, null); // expect warning
    }
}

Example

@jcouv jcouv self-assigned this Aug 5, 2018
@jcouv jcouv assigned cston and unassigned jcouv Aug 29, 2018
@cston
Copy link
Member Author

cston commented Aug 29, 2018

yield is tracked in #23701.

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