google / google/closure-compiler
Need a better error message for `yield` outside a generator
Open
Parser
- Dominant language
- JavaScript
- Stars
- 7.7k
- Forks
- 1.2k
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 6
Description
[Repro][1]
The following input
```js
yield;
```
produces a very cryptic error message:
```
input0:1: ERROR - Parse error. primary expression expected
yield;
^
```
It should probably be improved to something like "ERROR - yield only allowed inside a generator". Presumably this is as simple as just adding an additional case in Parser#parsePrimaryExpression right before the `default` to throw a different error for a `YIELD` token.
[1]: https://closure-compiler-debugger.appspot.com/#input0%3Dyield%253B%26input1%26conformanceConfig%26externs%26refasterjs-template%26includeDefaultExterns%3D1
Contributor guide
Assessment
This issue has not been assessed yet.