Bug 172848

Summary: [formatter] code formatter produces syntax error (unary operator+ followed by prefix increment operator++)
Product: [Eclipse Project] JDT Reporter: Sebastian Haufe <eclipse>
Component: CoreAssignee: Olivier Thomann <Olivier_Thomann>
Status: VERIFIED FIXED QA Contact:
Severity: trivial    
Priority: P3 CC: philippe_mulet
Version: 3.2.1   
Target Milestone: 3.3 M6   
Hardware: PC   
OS: Linux   
Whiteboard:
Attachments:
Description Flags
Proposed fix
none
Regression tests none

Description Sebastian Haufe CLA 2007-02-05 08:06:26 EST
Build ID: M20060921-0945

Steps To Reproduce:
format the following code snippet:

int i = 0;
int k = + ++i;

results in:

int i = 0;
int k = +++i;
        ^^^^ Invalid argument to operation ++/--

More information:
it is quite untypical to use the unary operator+ followed by prefix increment operator.  The reason to use it at all is, to make the code more readable.  Here my original code snippet:

/* check for terminal symbols*/
switch (translated = ALPHABET[read]) {
case TERMINAL_SYMBOL:  step = - ++wordIndex;
break;
default:               step = + ++wordIndex;
break;
}
                              ^^^^
Comment 1 Olivier Thomann CLA 2007-02-05 09:45:28 EST
Created attachment 58255 [details]
Proposed fix
Comment 2 Olivier Thomann CLA 2007-02-05 09:46:04 EST
Fix is trivial.
Philippe, I guess too late for 3.2.2?
Comment 3 Olivier Thomann CLA 2007-02-05 09:51:05 EST
Created attachment 58256 [details]
Regression tests
Comment 4 Olivier Thomann CLA 2007-02-08 10:13:40 EST
Released for 3.3M6.
Regression tests added in org.eclipse.jdt.core.tests.formatter.FormatterRegressionTests#test650/653
Comment 5 Olivier Thomann CLA 2007-02-08 10:18:38 EST
Regression two more tests added in
org.eclipse.jdt.core.tests.formatter.FormatterRegressionTests#test654/655
Comment 6 David Audel CLA 2007-03-20 13:40:15 EDT
Verified for 3.3 M6 using build I20070320-0010