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 193548 - Javascript global variable shadowed by function parameter
Summary: Javascript global variable shadowed by function parameter
Status: RESOLVED FIXED
Alias: None
Product: javascript
Classification: Unclassified
Component: Editor (show other bugs)
Version: 7.0
Hardware: PC All
: P3 normal (vote)
Assignee: Martin Fousek
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-12-17 11:52 UTC by emi
Modified: 2012-09-14 14:34 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Patch which fixes the issue (as mercurial bundle file, against the main repository) (1.68 KB, application/octet-stream)
2010-12-17 11:54 UTC, emi
Details
Standard patch file (has the same fix as the bundle). (2.30 KB, patch)
2011-01-05 14:22 UTC, emi
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description emi 2010-12-17 11:52:17 UTC
Hy,

In a situation like this:

var global = 10;

function f(global){
}

'var global' is a global variable that loses the green color highlighting due to the function parameter by the same name.

The problem seems to be in javascript.editing/src/org/netbeans/modules/javascript/editing/VariableVisitor.java

See the attached patch which fixes this bug. Global variable handling isn't quite perfect there and I've noticed a TODO from Tor "// TODO - track global assignments separately from", etc. but this small patch does get rid of this particular issue.

Please note that the patch is a mercurial bundle with my changeset -- I'm curious if it can be imported as-is. If not, I can also upload the patch file.
Comment 1 emi 2010-12-17 11:54:58 UTC
Created attachment 104205 [details]
Patch which fixes the issue (as mercurial bundle file, against the main repository)

I've marked the content type as application/octet-stream. There doesn't seem to be a mimetype for mercurial bundles and checking 'patch' might wrongly assume it's a text file.
Comment 2 emi 2011-01-05 14:22:10 UTC
Created attachment 104736 [details]
Standard patch file (has the same fix as the bundle).
Comment 3 Martin Fousek 2012-09-14 14:34:40 UTC
Hi emi,
thanks a lot for providing the patch. Finally the javascript editor was rewritten from scratch so I can't apply it any more. Anyway issue you mentioned is already resolved in the new javascript model, so it should work well to you now. Thanks again for contribution and feel free to test new javascript in our latest development builds:
http://bits.netbeans.org/download/trunk/nightly/latest/

Thanks...