Skip to content

Incorrect "Use of unassigned local variable" for (x is T y) == false. #20969

@NightElfik

Description

@NightElfik

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.

if ((variable is Type x) == false) {
    return;
}
x.Function();

This should be logically equivalent to code above and it works fine.

if (!(variable is Type x)) {
    return;
}
x.Function();

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!

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions