Bug 38895 - Unhelpful syntax diagnosis
Summary: Unhelpful syntax diagnosis
Status: RESOLVED WORKSFORME
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.1   Edit
Hardware: PC Windows 2000
: P3 normal (vote)
Target Milestone: 3.0 M9   Edit
Assignee: David Audel CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-06-13 12:05 EDT by Philipe Mulet CLA
Modified: 2004-05-06 07:49 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 Philipe Mulet CLA 2003-06-13 12:05:24 EDT
DiagnoseParser as of 06/13/2003

When following syntax error (in #newLibraryEntry()) is diagnosed, the end 
result is confusing, especially due to the highlighting.

public class X {

	public static void main(String[] args) {
	}
	public static int newLibraryEntry() {
			
		if (sourceAttachmentPath != null) {
			if (sourceAttachmentPath.isEmpty()) { && !
sourceAttachmentPath.isAbsolute()) {
			foo();
		}
		return null;
	}
	}
	
	public void foo() {
	}

	public void bar() {
	}
}

Error diagnosis is:

Severity	Description	Resource	In Folder	Location
	Creation Time
	Syntax error on token "{", invalid AssignmentOperator	X.java	Crap/src
	line 12	June 13, 2003 6:02:40 PM
	Syntax error on token "&&", invalid PushLPAREN	X.java	Crap/src
	line 12	June 13, 2003 6:02:40 PM
	Syntax error on token(s), misplaced construct(s)	X.java	Crap/src
	line 9	June 13, 2003 6:02:40 PM
Comment 1 Olivier Thomann CLA 2003-08-22 11:53:47 EDT
Change milestone.
Comment 2 David Audel CLA 2004-05-03 09:55:10 EDT
In build 20040428 the error messages are
Syntax error on token "&&", invalid (
Syntax error on token "{", invalid AssignmentOperator

The corrected code is
if (sourceAttachmentPath.isEmpty()) {
  (!sourceAttachmentPath.isAbsolute()) = foo();
}
This code is not semanticaly correct but is syntaxicaly correct

Grammar rules
Assignment ::= PostfixExpression AssignmentOperator AssignmentExpression
PostfixExpression -> Primary
Primary -> PrimaryNoNewArray
PrimaryNoNewArray ::=  PushLPAREN Expression PushRPAREN 

Are you agree to consider this bug as fixed ?
Comment 3 Philipe Mulet CLA 2004-05-06 06:35:36 EDT
Ok for me.
Comment 4 David Audel CLA 2004-05-06 07:49:37 EDT
Problem solved in a previous build

Test added
   ParserTests#test20()