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

False positive in SA1119, if (!(value is Type type)) erroneously reports inner parentheses unnecessary. #2517

Closed
Flynn1179 opened this issue Aug 15, 2017 · 4 comments

Comments

@Flynn1179
Copy link

Flynn1179 commented Aug 15, 2017

This is a new one in C#7

The ability to also declare a variable using a type pattern causes the unnecessary parenthesis warning to appear.

This works, and correctly allows it with no warning:

if (!(value is Type)) { .. }

This doesn't:

if (!(value is Type type)) { /* do something with type */ }

The inner parenthesis are reported as unnecessary, but they're definitely not.

@sharwell
Copy link
Member

Duplicate of #2372 😄

@Flynn1179
Copy link
Author

Odd, I searched for SA1119, didn't find it. Sorry!

@sharwell
Copy link
Member

@Flynn1179 No problem, we prefer a duplicate than no issue filed at all 😄

@Flynn1179
Copy link
Author

Ah, identified my error: I left the default is:open clause in the search, and didn't consider the possibility it had already been fixed, having updated to the latest released version this morning. Lesson learned!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants