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

RCS1211 and RCS1031 can introduce new compiler errors. #1040

Closed
jamesHargreaves12 opened this issue Feb 15, 2023 · 1 comment
Closed

RCS1211 and RCS1031 can introduce new compiler errors. #1040

jamesHargreaves12 opened this issue Feb 15, 2023 · 1 comment

Comments

@jamesHargreaves12
Copy link
Contributor

jamesHargreaves12 commented Feb 15, 2023

For cases, where the same local variable is declared inside the if and else blocks e.g.

if (flag)
{
    var x  = 1;
    return x;
}
else 
{
    var x = 0;
    return x;
}

The diagnostic RCS1211 Should not be raised.

Removing the else block would cause a compiler error "A local variable named 'x' cannot be declared in this scope because it would give a different meaning to 'x', which is already used in a parent or current scope to denote something else".

The same thing is true for switch case brackets (RCS1031).

Fix and tests in #1039.

@jamesHargreaves12
Copy link
Contributor Author

Fixed by the following PRs:
#1062
#1039

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

No branches or pull requests

1 participant