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

Bug 496313

Summary: Wrong no-undef-expression error reported for array access
Product: [ECD] Orion Reporter: Olivier Thomann <Olivier_Thomann>
Component: JS ToolsAssignee: Olivier Thomann <Olivier_Thomann>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: Michael_Rennie
Version: 11.0Flags: Michael_Rennie: review+
Target Milestone: 12.0   
Hardware: PC   
OS: Windows 7   
Whiteboard:
Attachments:
Description Flags
Proposed patch including regression tests none

Description Olivier Thomann CLA 2016-06-17 13:25:40 EDT
The following code:
var f = function() {};
var g = function() {};
const funcs = [f, g];
function func(i) {
    return funcs[i - 1]();
}
returns 'undefined' is undefined for Array in ...

This is just plain wrong. The problem comes from the fact that the no-undef-expression check gets undefined when getting the property name for 'i - 1'. I think in this case, we should simply skip the check if there is no property name.
Comment 1 Olivier Thomann CLA 2016-06-17 13:29:17 EDT
I would vote to fix this for 12.0. This doesn't look too good for array access.
Comment 2 Olivier Thomann CLA 2016-06-17 13:43:42 EDT
Created attachment 262518 [details]
Proposed patch including regression tests
Comment 3 Olivier Thomann CLA 2016-06-17 13:53:31 EDT
Delivered. Closing as fixed.
Michael, please review.