Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 351348

Summary: [validation] False "variable is never read" warning with certain variable names
Product: [WebTools] JSDT Reporter: Klaus Reimer <k>
Component: GeneralAssignee: Project Inbox <jsdt.javascript-inbox>
Status: RESOLVED WORKSFORME QA Contact: Chris Jaun <cmjaun>
Severity: normal    
Priority: P3    
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Whiteboard:

Description Klaus Reimer CLA 2011-07-06 11:50:50 EDT
Build Identifier: I20110613-1736

The following small code generates a "variable location is never read" warning which is wrong because the variable IS read.

    function test()
    {
        var location;
        
        location = { foo: 42 };
        return location.foo;
    }

Interesting facts:

  1. It does NOT happen when returning location["foo"] instead of location.foo.

  2. It does NOT happen when using a different variable name. It is reproducible with "location" and "window" and "document" (and may be others) but not with variable names which doesn't collide with pre-defined top-level variables. So maybe this warning collides with the "hides another field or variable" warning? But I couldn't reproduce it with a custom variable name which is also defined in the global scope.


Reproducible: Always
Comment 1 Chris Jaun CLA 2013-08-01 13:39:04 EDT
This is working correctly in WTP 3.5.1. Checked against 7/18 build.