Bug 64222 - [parsing] Misleading error message for around advice without return type
Summary: [parsing] Misleading error message for around advice without return type
Status: RESOLVED FIXED
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: 1.2   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 1.6.1   Edit
Assignee: Adrian Colyer CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-05-26 16:13 EDT by Macneil Shonle CLA
Modified: 2008-06-10 15:17 EDT (History)
1 user (show)

See Also:


Attachments

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