-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Incorrect "Use of unassigned local variable" for (x is T y) == false
.
#20969
Comments
📝 Note that for typical C# developers, the use of static void SomeExtension<T>(this List<T> list)
{
if (list?.Any() != true)
{
// The list is null or empty
return;
}
// do something here...
} |
Oh nevermind, I assumed that there was a request to allow I do know a number of C# developers who prefer using |
The C# |
@NightElfik Very interesting case. As Neal points out, this is currently by design as per the C# language, and dotnet/roslyn is for bugs on the C# compiler.
Ah! Quite possibly. For us to do that, we'd need a proposal filed over at https://github.com/dotnet/csharplang . Basically, i think we want a proposal that says that definite assignment should take into account boolean expressions involving == and != when compared to a constant boolean value. |
Thanks @CyrusNajmabadi, I have opened a new proposal at dotnet/csharplang. |
Version Used:
Microsoft Visual Studio Community 2017
Version 15.2 (26430.16) Release
VisualStudio.15.Release/15.2.0+26430.16
Microsoft .NET Framework
Version 4.6.01586
Steps to Reproduce:
This produces "Use of unassigned local variable" but it should not.
This should be logically equivalent to code above and it works fine.
We like to use
== flase
instead of!
in our code base for added readability. Unfortunately this does not work with above statement :/ Would it be possible to add it?Thanks!
The text was updated successfully, but these errors were encountered: