Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 168232

Summary: [1.5][compiler] Improve error message in case of creation of array with type arguments
Product: [Eclipse Project] JDT Reporter: Olivier Thomann <Olivier_Thomann>
Component: CoreAssignee: David Audel <david_audel>
Status: CLOSED WONTFIX QA Contact:
Severity: normal    
Priority: P3 CC: david_audel, Olivier_Thomann, philippe_mulet
Version: 3.3   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard: stalebug

Description Olivier Thomann CLA 2006-12-15 11:52:54 EST
Using HEAD,

public class X {
	String[] foo = new <Zork>String[] {};
}

compiling this code reports a syntax error. This is right, but we might want to see if we can "eat" it in the parser to report an error when resolving the type.
This would allow us to report a better error message. Something like:
array type cannot have type arguments
instead of:
----------
1. ERROR in d:\tests_sources\X.java (at line 2)
	String[] foo = new <Zork>String[] {};
	               ^^^^^^^^^^^^^^^^^^
Syntax error on token(s), misplaced construct(s)
----------
2. ERROR in d:\tests_sources\X.java (at line 2)
	String[] foo = new <Zork>String[] {};
	                        ^
Syntax error on token ">", , expected
----------
2 problems (2 errors)
Comment 1 Olivier Thomann CLA 2006-12-15 11:56:26 EST
Regression test added in org.eclipse.jdt.core.tests.compiler.regression.GenericTypeTest#test1102
Comment 2 Olivier Thomann CLA 2006-12-15 12:48:35 EST
We would need to add new rules in the grammar. Looks doable.
Philippe, David,

Do you believe this would improve our error reporting? Since we don't have a syntax error anymore, it should help.
Of course we should also double-check what we do in term of AST conversion, code completion and code selection.
Comment 3 Eclipse Genie CLA 2019-03-03 00:09:04 EST
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.