Summary: | Unexpected compile errors when abstract method missing return type | ||
---|---|---|---|
Product: | [Eclipse Project] JDT | Reporter: | John Arthorne <john.arthorne> |
Component: | Core | Assignee: | Olivier Thomann <Olivier_Thomann> |
Status: | RESOLVED FIXED | QA Contact: | |
Severity: | normal | ||
Priority: | P3 | CC: | peter_burka, philippe_mulet |
Version: | 2.0 | ||
Target Milestone: | 2.0 M3 | ||
Hardware: | PC | ||
OS: | Windows 2000 | ||
Whiteboard: |
Description
John Arthorne
2002-01-24 11:35:52 EST
The only parsing rules which can digest a missing return type method is a constructor one, which cannot be abstract and thus expects a block body (not a semi-colon one). This explains the parse error (we could investigate improving this). The first error though is more embarrassing. First reported error is due to the fact our syntax recovery did not position the bit for semi-colon body method, thus fooling the method check later on. This one is fixed. Now I obtain the following 2 errors: ---------- 1. ERROR in d:\Agent.java (at line 7) public abstract listen(String message); ^^^^^^^^^^^^^^^^^^^^^^ Return type for the method is missing ---------- 2. ERROR in d:\Agent.java (at line 7) public abstract listen(String message); ^ Syntax error on token ";", "{" expected ---------- I agree that the second one isn't very helpful, but the proper diagnosis is on the number one (and the second could be discared with a parser change: tolerate constructor with semi-colon body). I think this latter change is interesting anyway, since it will improve our behavior for recovery in general. Olivier - can you please investigate if this grammar change is breaking anything (still no ambiguity as I would expect). Regression test added (NegativeTests.test253), will need to be tuned after complete fix (with grammar change). The second error is gone after changing the grammar to consume silently the constructor without a body. See consumeInvalidConstructorDeclaration on the Parser. Released in HEAD. All tests are green and the NegativeTests.test253 has been updated to remove the second error. |