Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 326046 - Wrong error messages in certain cases when code is not compiling
Summary: Wrong error messages in certain cases when code is not compiling
Status: VERIFIED WONTFIX
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.7   Edit
Hardware: PC Windows XP
: P4 minor (vote)
Target Milestone: 4.14 M1   Edit
Assignee: Ayushman Jain CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2010-09-23 09:04 EDT by Krzysztof Kazmierczyk CLA
Modified: 2019-10-10 01:37 EDT (History)
4 users (show)

See Also:


Attachments
error message screenshot (8.86 KB, image/png)
2010-09-23 09:06 EDT, Krzysztof Kazmierczyk CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Krzysztof Kazmierczyk CLA 2010-09-23 09:04:06 EDT
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
Comment 1 Krzysztof Kazmierczyk CLA 2010-09-23 09:06:03 EDT
Created attachment 179454 [details]
error message screenshot
Comment 2 Stephan Herrmann CLA 2010-09-23 09:42:24 EDT
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.
Comment 3 Olivier Thomann CLA 2010-09-23 09:46:19 EDT
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.
Comment 4 Krzysztof Kazmierczyk CLA 2010-09-24 02:35:27 EDT
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.
Comment 5 Olivier Thomann CLA 2010-09-30 08:55:57 EDT
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.
Comment 6 Eclipse Genie CLA 2019-09-22 10:56:01 EDT
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.
Comment 7 Stephan Herrmann CLA 2019-09-22 13:46:48 EDT
(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.
Comment 8 Jay Arthanareeswaran CLA 2019-10-10 01:37:09 EDT
Verified for 4.14 M1