Bug 172848 - [formatter] code formatter produces syntax error (unary operator+ followed by prefix increment operator++)
Summary: [formatter] code formatter produces syntax error (unary operator+ followed by...
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.2.1   Edit
Hardware: PC Linux
: P3 trivial (vote)
Target Milestone: 3.3 M6   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-02-05 08:06 EST by Sebastian Haufe CLA
Modified: 2007-03-20 13:40 EDT (History)
1 user (show)

See Also:


Attachments
Proposed fix (2.02 KB, patch)
2007-02-05 09:45 EST, Olivier Thomann CLA
no flags Details | Diff
Regression tests (5.87 KB, patch)
2007-02-05 09:51 EST, Olivier Thomann CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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