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

LINQ operators disregard nullabilities #44913

Closed
nxtn opened this issue Jun 6, 2020 · 1 comment
Closed

LINQ operators disregard nullabilities #44913

nxtn opened this issue Jun 6, 2020 · 1 comment
Labels
Area-Compilers Resolution-Duplicate The described behavior is tracked in another issue

Comments

@nxtn
Copy link
Contributor

nxtn commented Jun 6, 2020

Version Used: Visual Studio 2019 Version 16.6.1

Steps to Reproduce:

#nullable enable

using System.Collections.Generic;
using System.Linq;

class MyClass
{
    static void Method()
    {
        _ = from MyClass item1 in Enumerate()
            select item1;

        foreach (MyClass item2 in Enumerate())
        //               ~~~~~ Warning	CS8600	Converting null literal or possible null value to non-nullable type.
        {
        }
    }

    static IEnumerable<MyClass?> Enumerate()
    {
        throw new NotImplementedException();
    }
}

Expected Behavior:

CS8600 is reported for both item1 and item2.

Actual Behavior:

CS8600 is only reported for item2.

@jcouv
Copy link
Member

jcouv commented Jun 6, 2020

Thanks for reporting this. It's a known issue/gap at the moment. We're still trying to figure out how to address it.
Closing as duplicate of #29863 (Implement nullability analysis in LINQ queries)

@jcouv jcouv closed this as completed Jun 6, 2020
@jcouv jcouv added Area-Compilers Resolution-Duplicate The described behavior is tracked in another issue labels Jun 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Compilers Resolution-Duplicate The described behavior is tracked in another issue
Projects
None yet
Development

No branches or pull requests

2 participants