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 249119 - Incorrect highlighting for variables
Summary: Incorrect highlighting for variables
Status: RESOLVED FIXED
Alias: None
Product: javascript
Classification: Unclassified
Component: Editor (show other bugs)
Version: 8.0.2
Hardware: PC Linux
: P3 normal (vote)
Assignee: Petr Pisl
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-12-04 17:40 UTC by DarioMenin
Modified: 2015-01-05 09:53 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
NetBeans 7.4 (correct) and 8.0.2 (wrong) (140.71 KB, image/png)
2014-12-04 17:40 UTC, DarioMenin
Details

Note You need to log in before you can comment on or make changes to this bug.
Description DarioMenin 2014-12-04 17:40:32 UTC
Created attachment 150887 [details]
NetBeans 7.4 (correct) and 8.0.2 (wrong)

Variables are incorrectly highlighted as unused or as global variables in functions, example:

function myFunction(param) {
    var f = param.f || function () {}, // usage is correctly detected
        a = param.a || 1;  // usage is correctly detected
    var g = function () {
        f();
        console.log(a);
    };
    g();
}
myFunction({a: 4});

The two screenshots show the wrong behaviour in NetBeans 8.0.2 and the correct behaviour in NetBeans 7.4
Comment 1 Vladimir Riha 2014-12-05 08:47:30 UTC
Reproducible, thank you for reporting

Product Version: NetBeans IDE Dev (Build 201412050001)
Java: 1.7.0_71; Java HotSpot(TM) Client VM 24.71-b01
Runtime: Java(TM) SE Runtime Environment 1.7.0_71-b14
System: Linux version 3.13.0-35-generic running on i386; UTF-8; en_US (nb)
Comment 2 DarioMenin 2014-12-05 13:30:56 UTC
If it could be useful to track down the problem, i checked the code above in NetBeans 8.0 WITHOUT UPDATES on another machine and the bug DOESN'T show, the Help -> About dialog says:

Product Version: NetBeans IDE 8.0 (Build 201403101706)
Updates: Updates available
Java: 1.8.0_25; Java HotSpot(TM) 64-Bit Server VM 25.25-b02
Runtime: Java(TM) SE Runtime Environment 1.8.0_25-b17
System: Linux version 3.8.0-44-generic running on amd64; UTF-8; it_IT (nb)

Regards,
Dario
Comment 3 Petr Pisl 2014-12-08 21:59:21 UTC
The problem is in the definition of variable f. If the definition will be without the function () {}, then it works correctly. So expression function () {} cased the problem.
Comment 4 Petr Pisl 2014-12-09 13:07:54 UTC
Fixed in web-main. Should be ok now.
Comment 5 Quality Engineering 2014-12-10 04:02:57 UTC
Integrated into 'main-silver', will be available in build *201412100001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/f58c8c5a4745
User: Petr Pisl <ppisl@netbeans.org>
Log: #249119 - Incorrect highlighting for variables
Comment 6 DarioMenin 2015-01-04 11:23:08 UTC
Hi, thank you very much for the fix, will it be available through the normal update channel?
Comment 7 Petr Pisl 2015-01-05 09:53:53 UTC
The fix is not complicated.  It can be integrated in a patch, if there will be. I'm not sure now.