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

Not inferring nullability of non-nullable value compared to null #32703

Closed
cston opened this issue Jan 23, 2019 · 3 comments
Closed

Not inferring nullability of non-nullable value compared to null #32703

cston opened this issue Jan 23, 2019 · 3 comments
Assignees
Labels
4 - In Review A fix for the issue is submitted for review. Area-Compilers Bug New Language Feature - Nullable Reference Types Nullable Reference Types
Milestone

Comments

@cston
Copy link
Member

cston commented Jan 23, 2019

Should report warnings for s.Length and c.F.ToString():

#pragma warning disable 0649
#pragma warning disable 8618

class C
{
    internal object F;
}

class Program
{
    static void F(string s, C c)
    {
        if (s == null)
            _ = s.Length;

        if (c.F != null) return;
        c.F.ToString();
    }
}
@gafter
Copy link
Member

gafter commented Jan 25, 2019

I'm not sure I agree. These are the moral equivalent of dead code.

@jaredpar jaredpar added the Bug label Jan 25, 2019
@jaredpar jaredpar added this to the 16.1.P1 milestone Jan 25, 2019
@jaredpar jaredpar added the Need Design Review The end user experience design needs to be reviewed and approved. label Jan 26, 2019
@jcouv
Copy link
Member

jcouv commented Feb 27, 2019

Subsumed by #33526 (Pure null tests should affect both branches)

@jcouv jcouv closed this as completed Feb 27, 2019
@jcouv
Copy link
Member

jcouv commented Feb 27, 2019

Re-opening issue as it is referenced in code (those references need to be removed first).
Sorry about that.

@jcouv jcouv reopened this Feb 27, 2019
@jcouv jcouv self-assigned this Feb 27, 2019
@jcouv jcouv removed the Need Design Review The end user experience design needs to be reviewed and approved. label Mar 7, 2019
@jcouv jcouv added the 4 - In Review A fix for the issue is submitted for review. label Mar 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4 - In Review A fix for the issue is submitted for review. Area-Compilers Bug New Language Feature - Nullable Reference Types Nullable Reference Types
Projects
None yet
Development

No branches or pull requests

4 participants