Since prettier-plugin-java migrated its parser from the Chevrotain-based java-parser to web-tree-sitter, valid Java that uses a contextual/restricted keyword as a statement label fails to parse.
prettier: 3.8.3
prettier-plugin-java: 2.9.7
- Last known-good:
prettier-plugin-java@2.6.0 (Chevrotain java-parser)
Minimal reproduction
public class T {
void m() {
record: while (true) {
break record;
}
}
}
Running plugin emits an error and prettier aborts, leaving the file unformatted.
$ prettier --plugin=prettier-plugin-java T.java
[error] T.java: Error: Failed to parse: (program (class_declaration ... body: (block (ERROR) (... )))) ...
Label keywords that fail:
record
yield
sealed
permits
var
open
module
requires
exports
to
with
A non-keyword label such as foo: works under both versions.
Since
prettier-plugin-javamigrated its parser from the Chevrotain-basedjava-parsertoweb-tree-sitter, valid Java that uses a contextual/restricted keyword as a statement label fails to parse.prettier: 3.8.3prettier-plugin-java: 2.9.7prettier-plugin-java@2.6.0(Chevrotainjava-parser)Minimal reproduction
Running plugin emits an error and prettier aborts, leaving the file unformatted.
Label keywords that fail:
recordyieldsealedpermitsvaropenmodulerequiresexportstowithA non-keyword label such as
foo:works under both versions.