Polish parser errors (#12258)

* polish: update AwaitNotInAsyncFunction message

* polish: update YieldInParameter error message

* Apply suggestions from code review

Co-authored-by: Brian Ng <bng412@gmail.com>

* update test fixtures

Co-authored-by: Brian Ng <bng412@gmail.com>
This commit is contained in:
Huáng Jùnliàng
2020-10-26 20:55:04 -04:00
committed by GitHub
parent 2782a549e9
commit 5b48f40a08
27 changed files with 56 additions and 46 deletions

View File

@@ -2343,7 +2343,12 @@ export default class ExpressionParser extends LValParser {
if (reservedTest(word, this.inModule)) {
if (!this.prodParam.hasAwait && word === "await") {
this.raise(startLoc, Errors.AwaitNotInAsyncFunction);
this.raise(
startLoc,
this.hasPlugin("topLevelAwait")
? Errors.AwaitNotInAsyncContext
: Errors.AwaitNotInAsyncFunction,
);
} else {
this.raise(startLoc, Errors.UnexpectedReservedWord, word);
}