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

No warning on uninitialized static non-nullable fields? #34668

Closed
stephentoub opened this issue Apr 2, 2019 · 0 comments · Fixed by #37507
Closed

No warning on uninitialized static non-nullable fields? #34668

stephentoub opened this issue Apr 2, 2019 · 0 comments · Fixed by #37507

Comments

@stephentoub
Copy link
Member

Version Used:
3.0.0-beta4-19170-01+1deafee3682da88bf07d1c18521a99f47446cee8

Repro:

#nullable enable
using System;

class Program
{
    private static object s_foo;

    static void Main() => Console.WriteLine(s_foo.GetHashCode());
}

There's no warning here, but it will obviously null ref. Shouldn't there be a warning for a non-nullable static field that's not initialized as part of the declaration or a static cctor?

cc: @cston, @jaredpar, @danmosemsft, @dotnet/nullablefc

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