Bug 312116 - Renaming a variable declared in for loop does not cover all instances
Summary: Renaming a variable declared in for loop does not cover all instances
Status: RESOLVED FIXED
Alias: None
Product: kdevelop
Classification: Applications
Component: Language Support: CPP (old) (other bugs)
Version First Reported In: git master
Platform: openSUSE Linux
: NOR normal
Target Milestone: ---
Assignee: kdevelop-bugs-null
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-12-23 13:51 UTC by Alexander Shaduri
Modified: 2016-12-13 08:02 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed/Implemented In: 5.0.0
Sentry Crash Report:


Attachments
Example code showing the bahaviour. (378 bytes, text/plain)
2013-02-27 15:36 UTC, Claus Christmann
Details
The bug has been resolved (578.06 KB, image/png)
2016-04-22 07:17 UTC, Sumeet Tulsani
Details
The bug has been Resolved (561.31 KB, image/png)
2016-04-22 07:19 UTC, Sumeet Tulsani
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Alexander Shaduri 2012-12-23 13:51:28 UTC
Hello,
I'm using KDevelop git master (2012-12-21).

Consider the following code:

for (int a = 0; a < 5; ++a) {
	int x = a;
}

now rename "a" by e.g. typing "b" after "a" and clicking 'Rename "a" to "ab"' in the popup. Here's the result:

for (int ab = 0; a < 5; ++a) {
	int x = ab;
}

As you can see, "a" has been renamed in the body of the for loop, but not on the first line.

Note that this does _not_ happen when using "Code -> Rename Declaration", every instance is renamed then.

Thanks

Reproducible: Always

Steps to Reproduce:
1. Try the example above.

Actual Results:  
The variable is not renamed in some places.

Expected Results:  
The variable should always be renamed.
Comment 1 Claus Christmann 2013-02-27 15:36:59 UTC
Created attachment 77615 [details]
Example code showing the bahaviour.
Comment 2 Claus Christmann 2013-02-27 15:40:37 UTC
Comment on attachment 77615 [details]
Example code showing the bahaviour.

When renaming the i, j, or k variables at their respective declarations, the auto-renaming behavior is flawed for single line {} scopes: auto renaming doe not work for i and j, but it does work for k.

A potentially related issue:
when the names for i,j, or k are altered where they are used, the behavior is also different:

renaming i<10; to i2<10; results in a prompt to declare int i2
renaming i++ to i2++ does not result in any prompt whatsoever
Comment 3 Sumeet Tulsani 2016-04-22 07:17:40 UTC
Created attachment 98505 [details]
The bug has been resolved

This screenshot suggests the use of Rename Declaration in KDevelop editor.
Comment 4 Sumeet Tulsani 2016-04-22 07:19:43 UTC
Created attachment 98506 [details]
The bug has been Resolved

This screenshot shows the screen after the use of Rename button, showing that the bug has been already resolved.