Summary: | [13] Improve error message for parse error on yield() method call | ||
---|---|---|---|
Product: | [Eclipse Project] JDT | Reporter: | Roman Guliak <keilj> |
Component: | Core | Assignee: | JDT-Core-Inbox <jdt-core-inbox> |
Status: | NEW --- | QA Contact: | |
Severity: | enhancement | ||
Priority: | P3 | CC: | loskutov, manoj.palat, stephan.herrmann |
Version: | 4.14 | Keywords: | helpwanted |
Target Milestone: | --- | ||
Hardware: | PC | ||
OS: | Windows 10 | ||
Whiteboard: |
Description
Roman Guliak
2020-02-14 06:19:06 EST
I can't reproduce on 4.12 / 4.15 head of today with both Java 8 / 11 libraries. Which Eclipse / JDK version are you using? I use org.eclipse.jdt.core-3.20.0.jar. Probably, it's 4.14. "level" is set to AST.JLS13, "compliance" is JavaCore.VERSION_13, preview features for Java 13 are enabled. For comparison: javac version 13: $ javac --release 13 --enable-preview Test1.java Test1.java:4: error: invalid use of a restricted identifier 'yield' yield(); ^ (to invoke a method called yield, qualify the yield with a receiver or type name) 1 error ecj (latest): $ ecj --release 13 --enable-preview Test1.java ---------- 1. ERROR in /tmp/Test1.java (at line 4) yield(); ^ Syntax error on token "(", Expression expected after this token ---------- 1 problem (1 error) If you change the call to "Thread.yield()" both compilers accept. Ergo: in whether or not a program is legal, both compilers agree. Just ecj's error message isn't very helpful in this particular situation. tentatively putting this on the radar - no promise yet. The worst thing in this case is that code that follows yield() is just skipped. I thought that when parser encounters other syntax errors it tries to recover somehow from them. For example, when a statement is missing a semicolon, an error is reported, but statements that follow the error are still present in AST. Is something similar possible in this case also? Bulk move out of 4.16 keeping in the radar for 4.18 bulk move out of 4.19 - retarget once an owner is assigned |