eclipse-jdt / eclipse-jdt/eclipse.jdt.core

[Records][Recovery] Bad parse tree recovery on syntax error in records class

Open
#3,880 0 comments 0 reactions 1 assignee Claimed by @srikanth-sankaran View on GitHub
Dominant language
Java
Stars
237
Forks
195
Avg merge
1d 12h
Merged PRs (30d)
47

Description

`org.eclipse.jdt.core.tests.compiler.regression.RecordsRestrictedClassTest.testBug561528_005()` contains this code:

```
class X {
public static void main(String[] args){
System.out.println(0);
}
}
interface Node {}
interface AB {}
interface CD {}
record R >>>> (N value){
}
```

and expects this error message:

"----------\n" +
"1. ERROR in X.java (at line 12)\n" +
" record R >>>> (N value){\n" +
" ^^^\n" +
"Syntax error on token \">>>\", >> expected\n" +
"----------\n"

For the record class R with the syntax error, the recovered parse tree is actually:

```
record R()>>> {
N value;
{
}
}
```

which is wrong. (But the error about instance field being declared in a record class does not surface because it gets short circuited)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.