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 209717 - Typeof keyword in IF statement causes problems with context of variables
Summary: Typeof keyword in IF statement causes problems with context of variables
Status: VERIFIED FIXED
Alias: None
Product: javascript
Classification: Unclassified
Component: Editor (show other bugs)
Version: 7.2
Hardware: PC Linux
: P3 normal (vote)
Assignee: Petr Pisl
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-03-19 07:35 UTC by Vladimir Riha
Modified: 2012-07-10 04:10 UTC (History)
1 user (show)

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 2012-03-19 07:35:28 UTC
Simple test case 1:

function test(foo, bar){
          foobar = (typeof foo == "undefined") ? bar : foo;
}

Place cursor inside the first or last occurrence of "foo" 
=> "foo" in the "(typeof foo == "undefined")" is not highlighted as it should be 

Another scenario:
- use the same code and change the 2nd line to this:
 foobar = (typeof foooo == "undefined") ? bar : foo;
=> variable foooo is not recognized as global (~undefined in the function)


Removing the typeof from the IF statements fixes both problems



Product Version: NetBeans IDE Dev (Build 201203180400)
Java: 1.7.0_03; Java HotSpot(TM) Client VM 22.1-b02
System: Linux version 3.0.0-16-generic running on i386; UTF-8; en_US (nb)
Comment 1 Vladimir Riha 2012-03-22 14:18:08 UTC
I don't want to create new issue, so I'll update this one.


In the new JS editor, if you use the mentioned test case then all instances of bar/foo are not highlighted on the line with "typeof".


Product Version: NetBeans IDE Dev (Build 2012-03-22_03-56-25 )
Comment 2 Petr Pisl 2012-03-23 08:36:23 UTC
Fixed all three mentioned problems. 
Thanks.
Comment 3 Vladimir Riha 2012-03-26 08:32:47 UTC
verified

Product Version: NetBeans IDE Dev (Build 2012-03-23_09-53-16 )
Comment 4 Quality Engineering 2012-07-10 04:10:55 UTC
Integrated into 'main-golden', will be available in build *201207100002* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/cda364884c7c
User: Petr Pisl <ppisl@netbeans.org>
Log: #209717 - Typeof keyword in IF statement causes problems with context of variables

This is fixing the part with mark occurences in the ternary node.