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 239967 - Variable incorrectly marked as local after assignment
Summary: Variable incorrectly marked as local after assignment
Status: VERIFIED FIXED
Alias: None
Product: javascript
Classification: Unclassified
Component: Editor (show other bugs)
Version: 8.0
Hardware: PC Linux
: P3 normal (vote)
Assignee: Petr Pisl
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-01-03 17:25 UTC by Vladimir Riha
Modified: 2014-01-17 10:35 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Vladimir Riha 2014-01-03 17:25:09 UTC
Please try following code in either JS file or embedded in HTML:

var pool = []; // purple

function makeRequests() {
    pool = []; // green
    for (var i = 0; i < numberOfRequests; i++) {
        pool[i] = i; // green
    }
}



and notice "pool" variable:
1) On line with declaration, it is purple but 2 following occurrences are green
2) Navigator shows pool twice, once in global scope, once below makeRequests function
3) if you select "purple" pool and press Ctrl+R, two following occurrences are not renamed (also "mark occurrences" ignores them). The same happens vice versa, if you try "green" pool and repeat, only 2nd green is highlighted/renamed, purple one is ignored.

It seems to be caused by the pool = [] inside makeRequests function. It is reproducible also if the entire code is inside another function

I'd vote for P2 but I don't have a string opinion (it is reproducible in 7.4 as well and no one noticed it) 


Product Version: NetBeans IDE Dev (Build 201401030002)
Java: 1.8.0-ea; Java HotSpot(TM) Client VM 25.0-b65
Runtime: Java(TM) SE Runtime Environment 1.8.0-ea-b122
System: Linux version 3.2.0-48-generic-pae running on i386; UTF-8; en_US (nb)
Comment 1 Vladimir Riha 2014-01-03 19:25:35 UTC
Seems like it happens just with [] array. If pool would be 

var pool = new Date()

and the same in makeRequests() it works, the same for {} or combination of both => P3
Comment 2 Petr Pisl 2014-01-16 10:37:05 UTC
Fixed in web-main.
Comment 3 Quality Engineering 2014-01-17 02:47:47 UTC
Integrated into 'main-silver', will be available in build *201401170001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/5c99a50720eb
User: Petr Pisl <ppisl@netbeans.org>
Log: #239967 - Variable incorrectly marked as local after assignment
Comment 4 Vladimir Riha 2014-01-17 10:35:13 UTC
Thank you, verified

Product Version: NetBeans IDE Dev (Build 201401170001)
Java: 1.8.0-ea; Java HotSpot(TM) Client VM 25.0-b65
Runtime: Java(TM) SE Runtime Environment 1.8.0-ea-b122
System: Linux version 3.2.0-48-generic-pae running on i386; UTF-8; en_US (nb)