Bug 23166

Summary: Syntax error message from Java compiler is confusing.
Product: [Eclipse Project] JDT Reporter: Wylie Garvin <wylie_garvin>
Component: CoreAssignee: David Audel <david_audel>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: 2.0   
Target Milestone: 3.0 M2   
Hardware: PC   
OS: Windows 2000   
Whiteboard:

Description Wylie Garvin CLA 2002-09-04 13:18:31 EDT
I created a new Class and typed the following into it:

public class FOOBY {
  Fribbit;
}

On saving this class, I get a syntax error at the ";" after Fribbit.  The 
compiler message is confusing because it does not distinguish the actual token 
it stopped at with the list of tokens it would accept instead:

  Syntax error on token ";", "=", "*=", "/=", "%=", "+=", "-
=", "<<=", ">>=", ">>>=", "&=", "^=", "|=" expected

The list of expected alternatives is comma-separated, and the actual token is 
followed by a comma.  It just looks like one big list.

Suggestion: put the 'expected' before the list:

  Syntax error on token ";", expected "=", "*=", ...

In cases like this, it would be more useful anyway if the message said:

Syntax error on token ";", expected assignment-operator

I.e. any time the list of alternatives is longer than 3, it is more distracting 
than actually useful.
Comment 1 Philipe Mulet CLA 2002-11-06 08:58:41 EST
Deferring post 2.1
Comment 2 Philipe Mulet CLA 2003-06-10 09:29:26 EDT
Reconsidering given new syntax error diagnosis heuristic
Comment 3 David Audel CLA 2003-07-01 06:57:27 EDT
Fixed.

The new error message is: Syntax error on token "Fribbit", VariableDeclarator 
expected after this token
Comment 4 David Audel CLA 2003-07-16 04:13:51 EDT
Verified.