| Summary: | Wrong error messages in certain cases when code is not compiling | ||||||
|---|---|---|---|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | Krzysztof Kazmierczyk <kazm> | ||||
| Component: | Core | Assignee: | Ayushman Jain <amj87.iitr> | ||||
| Status: | VERIFIED WONTFIX | QA Contact: | |||||
| Severity: | minor | ||||||
| Priority: | P4 | CC: | jarthana, kazm, Olivier_Thomann, stephan.herrmann | ||||
| Version: | 3.7 | ||||||
| Target Milestone: | 4.14 M1 | ||||||
| Hardware: | PC | ||||||
| OS: | Windows XP | ||||||
| Whiteboard: | stalebug | ||||||
| Attachments: |
|
||||||
Created attachment 179454 [details]
error message screenshot
It is indeed difficult for the parser to infer what exactly was your
intention, in order to report the error at the exact location where you
erred. However, the error location does include:
"final String name = document.getName("
which is not a valid statement but it is terminated with ";"
Isn't that enough of a hint for what's wrong here?
The only issue I see is that the problem marker has to be set for
a specific line of code, whereas the problem location actually spans
two lines.
This is about what the error recovery can do. There is no perfect solution there and this is not something on the plan right now. In your case, given the reported markers it is quite easy to spot the syntax error even if the messages are not great. No plan to improve that right now. If you want to provide a patch, feel free to do it. Closing as WONTFIX. Oliver, what about such code:
private void printProperties(OleAutomation document2) {
for (int i = 0; i < 10000; i++) {
System.out.println("koko");
int b = 0;
while (true) {
b++;
}
final String name = document.getName(;)
if (name != null) System.out.println(i + " " + name);
}
}
Do you think that in such code still be easy to find where exactly error is?
Feel free to close it again if you are not going to fix it.
Ayushman, please investigate if the last case can be improved. If you remove the "for statement" (for line + closing brace), the reported error is much better. This is time permitting. This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant. -- The automated Eclipse Genie. (In reply to Krzysztof Kazmierczyk from comment #4) > Oliver, what about such code: > > private void printProperties(OleAutomation document2) { > for (int i = 0; i < 10000; i++) { > System.out.println("koko"); > int b = 0; > while (true) { > b++; > } > final String name = document.getName(;) > if (name != null) System.out.println(i + " " + name); > } > > } > > Do you think that in such code still be easy to find where exactly error is? Errors reported by 4.13 are: on "document": document cannot be resolved on "(": Syntax error, insert ";" to complete LocalVariableDeclarationStatement Syntax error, insert ")" to complete MethodInvocation Note, that in 4.13 the for loop has no impact on the errors given. > Feel free to close it again if you are not going to fix it. Looks sufficiently well for me. Verified for 4.14 M1 |
Build Identifier: I20100805-1700 When developing code I encountered silly messages produced by Eclipse compiler. See steps to reproduce. Reproducible: Always Steps to Reproduce: 1. Create new Class 2. Insert into class following method: private void printProperties(OleAutomation document2) { for (int i = 0; i < 10000; i++) { final String name = document.getName(;) if (name != null) System.out.println(i + " " + name); } } (you must import OLEAutomation class). 3. You have syntax error token/misplaced constructor in the line "for (int i = 0; i < 10000; i++) {" and other silly errors in next lines despite the fact given line is correct