Commit f7cf55b
authored
fix: report a missing class name as a syntax error
A class declaration with no name did not produce a SyntaxError:
class {} no message resource found for message id: parser.error.expected.ident
class 1 {} same
className() asked for the message key parser.error.expected.ident, which does
not exist. ECMAErrors.getMessage turns the MissingResourceException into a plain
RuntimeException, so the error was neither a ParserException nor - under
JSR-223 - a ScriptException.
There is no need for a new key: this is the same "Expected X but found Y" that
expectDontAdvance reports everywhere else, so className() now builds it the same
way, through the existing "expected" key. That also fixes the argument, which
named the token being looked at rather than the one that was wrong: the message
said "class" where the offending token was "{".
class {} Expected ident but found {
class 1 {} Expected ident but found 1
Two error tests come with it. Neither a malformed class name nor a duplicated
constructor had one, which is why a message key that never resolved could ship.
The duplicate-constructor message was already correct and is now covered.
./gradlew build testOptimistic testPessimistic:
suite before after
test 665, 0 fail 665, 0 fail
testOptimistic 1715, 0 fail 1717, 0 fail
testPessimistic 1715, 0 fail 1717, 0 fail1 parent 100129d commit f7cf55b
5 files changed
Lines changed: 75 additions & 1 deletion
File tree
- src/main/java/org/codelibs/sai/internal/parser
- test/script/error
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1119 | 1119 | | |
1120 | 1120 | | |
1121 | 1121 | | |
1122 | | - | |
| 1122 | + | |
| 1123 | + | |
| 1124 | + | |
1123 | 1125 | | |
1124 | 1126 | | |
1125 | 1127 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
0 commit comments