This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
Summary: | [rename-refactoring] NB silently renames a variable inside a inner block to a name of an existent one outside | ||
---|---|---|---|
Product: | cnd | Reporter: | gugawag |
Component: | Code Model | Assignee: | Vladimir Voskresensky <vv159170> |
Status: | REOPENED --- | ||
Severity: | normal | CC: | gugawag |
Priority: | P3 | ||
Version: | 7.2.1 | ||
Hardware: | All | ||
OS: | All | ||
See Also: |
http://netbeans.org/bugzilla/show_bug.cgi?id=223898 http://netbeans.org/bugzilla/show_bug.cgi?id=223937 |
||
Issue Type: | DEFECT | Exception Reporter: |
Description
gugawag
2012-12-17 14:26:05 UTC
Its reproducible in any inner block, like switch, for example: 1 - #include <stdio.h> int main(void){ int i = 2; int two = 2; switch(i){ int three = 3; case 1: { printf("%d", 1); break; } case 2: { printf("%d", two); break; } } return 0; } output: 2 2 - rename the three variable inside switch block to "two": #include <stdio.h> int main(void){ int i = 2; int two = 2; switch(i){ int two = 3; //refactored case 1: { printf("%d", 1); break; } case 2: { printf("%d", two); break; } } return 0; } new output: 3 please do not file cnd-related stuff on apisupport product but cnd instead Please describe expected behavior. The functionality works as designed. Dear Leonid. By the refactoring theory, any type of transformation that refactoring tools do in a code has to maintain the behavior of this code. In the case of this issue, NB change the variable name and the output of the program changed from 2 to 3, what is considered a bug by the refactoring point of view. In this case, NB must prevent to do this transformation. Eclipse CDT does not allow this refactoring, since there is another variable with the same name and this transformation could lead to a behavioral change (it cannot be done in refactoring theory). See Eclipse CDT images attached. In the first one, it informs that there is a conflict. Even so, the user can click preview (image 2) and performs the refactoring. But, at least, eclipse informed the user about the possible issue. |