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

RCS1031: False positive when local variables share names #801

Closed
eduherminio opened this issue May 8, 2021 · 1 comment
Closed

RCS1031: False positive when local variables share names #801

eduherminio opened this issue May 8, 2021 · 1 comment

Comments

@eduherminio
Copy link
Member

Product and Version Used:

Roslynator 2019 VS Extension, v3.2.0

Steps to Reproduce:

var key = "key_1";
var value = "false";

switch (key)
{
    case "key_1":
    {
        bool.TryParse(value, out var val);
        break;
    }
    case "key_2":
    {
        bool.TryParse(value, out var val);
        break;
    }
    // ...
}

Actual Behavior:
RCS1031: Remove unnecessary braces.
Applying the suggestion raises CS0136.

Expected Behavior:
No warning raised, since the braces cannot be removed without producing the compiler error due to out var val used in both switch sections.

@josefpihrt
Copy link
Collaborator

fixed with #1039

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