Bug 25377 - Error location is not correct for empty array initializer
Summary: Error location is not correct for empty array initializer
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.0   Edit
Hardware: PC Windows 2000
: P3 normal (vote)
Target Milestone: 2.1 M3   Edit
Assignee: David Audel CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-10-25 08:56 EDT by David Audel CLA
Modified: 2002-11-13 05:37 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description David Audel CLA 2002-10-25 08:56:55 EDT
build 20021022

1) Create the following class
----------------------------
public class X {
   public void foo() {
      if(true) {
      }
      Object o = {};
   }
}
----------------------------
2) Compile this class
There 1 error "Type mismatch: cannot convert from Object[] to Object"
3) select this error in task view
The selected text is :
----------------------------
               {
      }
      Object o = {}
----------------------------
Comment 1 David Audel CLA 2002-10-25 09:05:36 EDT
In 'Parser#arrayInitializer(int length)' , 'searchPosition' is not correctly 
initialized.

It is:
int searchPosition = length == 0 ? endPosition : ai.expressions[0].sourceStart;
But it must be:
int searchPosition = length == 0 ? endPosition + 1 : ai.expressions
[0].sourceStart;

Fixed.
Comment 2 David Audel CLA 2002-11-13 05:37:41 EST
Verified.