Bug 23166 - Syntax error message from Java compiler is confusing.
Summary: Syntax error message from Java compiler is confusing.
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.0   Edit
Hardware: PC Windows 2000
: P3 normal (vote)
Target Milestone: 3.0 M2   Edit
Assignee: David Audel CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-09-04 13:18 EDT by Wylie Garvin CLA
Modified: 2003-07-16 04:13 EDT (History)
0 users

See Also:


Attachments

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