Bug 22139

Summary: Array initializer used inline causes syntax error
Product: [Eclipse Project] JDT Reporter: Robin Rosenberg <robin.rosenberg>
Component: CoreAssignee: Philipe Mulet <philippe_mulet>
Status: VERIFIED FIXED QA Contact:
Severity: minor    
Priority: P3    
Version: 2.0   
Target Milestone: 2.1 M4   
Hardware: All   
OS: All   
Whiteboard:

Description Robin Rosenberg CLA 2002-08-02 20:13:07 EDT
When an initialized array is used directly Eclipse is incompatible with JDK     
1.3/1.4. Both lines compile without warning with Sun's compiler.    
   
The workaround is simple, just add parentheses.    
    
class as {    
 {     
    int x=new int[] { 1,3,4 }[0]; // Syntax error on token "[", ";" expected    
    int y=(new int[] { 1,3,4 })[0]; //     
 }    
}    
    
My platform is Eclipse GTK, build 200206271827, Linux Mandrake 8.2 i586.
Comment 1 Olivier Thomann CLA 2002-12-11 17:25:44 EST
This was fixed with the latest changes in the parser.
I checked that this code compiles fine using the integration build 1210.
Comment 2 David Audel CLA 2002-12-18 05:36:58 EST
Verified.