semantic-refactor
semantic-refactor copied to clipboard
c++: variable scope problems with 'rename'
In the following code, when I put the cursor on the first occurrence of i (the declaration) and ask for a rename, only the declaration is renamed - not the other occurrences of i (in i < 3, i++, cout << i, etc.).
for (int i = 0; i < 3; i++) {
cout << i;
}
If I declare 'i' externally, then there are still scoping issues.
for (int i = 0; i < 3; i++) { // incorrectly renamed
cout << i; // incorrectly renamed
}
int i; // <- run rename on this 'i'
for (i = 0; i < 3; i++) { // these are renamed, correctly
}
then all instances of i are renamed, even those from the first for loop.