Bug 64222

Summary: [parsing] Misleading error message for around advice without return type
Product: [Tools] AspectJ Reporter: Macneil Shonle <mshonle>
Component: CompilerAssignee: Adrian Colyer <adrian.colyer>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: aclement
Version: 1.2   
Target Milestone: 1.6.1   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Macneil Shonle CLA 2004-05-26 16:13:06 EDT
If you try to compile the code:

class C {
	int dummy() {return 5;}
}

aspect Foo {
	around(): call(int C.dummy()) {
		proceed();
	}
}

You'll get an error, highlighting the "aspect Foo {" line that says:

    Syntax error on token "{", Type expected after this token

Granted, the error might be obvious in this case, but if the preceeding line is
a complex pointcut, one might be lead to believe there is something wrong with
their pointcut instead.

A better error message would highlight the line that "around" appears and say
something more like

    Syntax error: around advice needs a return type specified

I believe an error production could probably be used to handle this relatively
common mistake.
Comment 1 Andrew Clement CLA 2008-01-22 13:51:21 EST
didnt get to it whilst the parser was open for 1.6.0m1
Comment 2 Andrew Clement CLA 2008-06-10 15:17:33 EDT
Hurrah!!! I fixed this, whilst I had the grammar open to address privileged generic aspects (*shudder*).

You now get a much nicer message actually indicating what the problem is!

D:\Andy\eclipse_ws\aspectj_ws\tests\bugs161\pr64222\C.java:6 [error] Syntax error, insert "return type" to complete around advice declaration

around(): call(int C.dummy()) {


I had to add a recovery rule to the grammar that recognizes the bad pattern of tokens that are missing a return type.