Local in outer scope defined after an inner block containing same-name local #5757
Unanswered
TahirAhmadov
asked this question in
Q&A
Replies: 1 comment
-
THis continues to find common coding mistakes for me. Where i actually intend there to be one variable, and i don't realize there are two in these scopes like this.
If the variable is set, and the not read before being written again, then we report an analyzer message in roslyn. If it is read, then it's entirely dependent on the domain if it's intended for the overwrite to be ok or not. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
But should it be? Why can't we make that legal? There is no confusion here - the "abc"
s
is done with and not accessible anymore.Currently, I end up having to do this:
The problem here is it can create a hidden bug:
Whereas if we made the change:
Beta Was this translation helpful? Give feedback.
All reactions