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.

Bug 131560 - Hyperlink does not distinguish variables with the same names within function body
Summary: Hyperlink does not distinguish variables with the same names within function ...
Status: VERIFIED FIXED
Alias: None
Product: cnd
Classification: Unclassified
Component: Code Model (show other bugs)
Version: 6.x
Hardware: All All
: P1 blocker (vote)
Assignee: Vladimir Voskresensky
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-03-30 22:11 UTC by Vladimir Kvashin
Modified: 2008-04-09 07:43 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
patch (1.29 KB, patch)
2008-04-05 17:37 UTC, Vladimir Voskresensky
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Vladimir Kvashin 2008-03-30 22:11:34 UTC
In C/C++ compound statement, you can declare the variable that has the same name 
as a variable outside the compound statement (upper than it).
Hyperlink, completion and XRef do not distingwish such variables.

Consider the code below.
It contains two "my_var" variables.
But hyperlink wrongly "thinks" that all my_var refers to the first declaration.

int main(int argc, char**argv) {
    int my_var = 17; 
    int i;
    for (i = 0; i < argc; i++) {
        int my_var = i;
        printf("%my_var: %i\n", my_var);
    }
    printf("%my_var: %i\n", my_var);
    return 0;
}
Comment 1 Vladimir Voskresensky 2008-04-05 14:37:03 UTC
rather serious bug accuracy...
Comment 2 Vladimir Voskresensky 2008-04-05 16:45:25 UTC
I see the reason, The fix is safe. Of course inner scope elements have priority
Comment 3 Vladimir Voskresensky 2008-04-05 17:37:21 UTC
Created attachment 59732 [details]
patch
Comment 4 Vladimir Voskresensky 2008-04-05 17:38:09 UTC
Vladimir K., please, review the fix.

all tests are OK
Comment 6 Vladimir Kvashin 2008-04-06 12:01:44 UTC
I reviewed the fix.
It is correct and safe.
I strongly agree that it's worth including it into 6.1
Comment 7 soldatov 2008-04-07 15:49:31 UTC
verified in 200804040802 build + jars with fixes from developers
Comment 8 Vladimir Voskresensky 2008-04-07 16:07:01 UTC
fix integrated in 6.1
http://hg.netbeans.org/release61?cmd=changeset;node=890335195656
Comment 9 soldatov 2008-04-09 07:43:44 UTC
verified in 200804082140 build (branch: release61)