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

Warning reported for dereference after first dereference with ! #31733

Closed
cston opened this issue Dec 13, 2018 · 2 comments
Closed

Warning reported for dereference after first dereference with ! #31733

cston opened this issue Dec 13, 2018 · 2 comments
Assignees
Labels
Area-Compilers Bug Feature - Nullable Reference Types Nullable Reference Types Resolution-Fixed The bug has been fixed and/or the requested behavior has been implemented
Milestone

Comments

@cston
Copy link
Member

cston commented Dec 13, 2018

Should not report a warning for x.GetHashCode() since the previous dereference in x!.ToString() succeeded:

#nullable enable

class Program
{
    static void F(object? x)
    {
        _ = x!.ToString();
        _ = x.GetHashCode(); // warning: may be null
    }
}
@cston
Copy link
Member Author

cston commented Dec 14, 2018

Note, subsequent warnings would not be reported if #31732 is implemented.

@jcouv
Copy link
Member

jcouv commented Dec 31, 2018

Closing as duplicate of #31732
Update: I now understand this is not exactly the same as the linked issue. On the first line we dereference x! and from that we should learn that x is not null.

@jcouv jcouv self-assigned this Jan 1, 2019
@jcouv jcouv added this to the 16.0.P2 milestone Jan 1, 2019
@jcouv jcouv added the 4 - In Review A fix for the issue is submitted for review. label Jan 1, 2019
@jaredpar jaredpar added the Bug label Jan 2, 2019
@jcouv jcouv added Resolution-Fixed The bug has been fixed and/or the requested behavior has been implemented and removed 4 - In Review A fix for the issue is submitted for review. labels Jan 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Compilers Bug Feature - Nullable Reference Types Nullable Reference Types Resolution-Fixed The bug has been fixed and/or the requested behavior has been implemented
Projects
None yet
Development

No branches or pull requests

3 participants