Make yield a contextual keyword (#9400)

This commit is contained in:
Daniel Tschinder
2019-01-23 14:33:23 -08:00
committed by GitHub
parent 42c5d3fc4b
commit 46ba5940c2
38 changed files with 768 additions and 126 deletions

View File

@@ -975,17 +975,9 @@ export default class StatementParser extends ExpressionParser {
this.initFunction(node, isAsync);
if (this.match(tt.star)) {
node.generator = true;
this.next();
}
node.generator = this.eat(tt.star);
if (
isStatement &&
!optionalId &&
!this.match(tt.name) &&
!this.match(tt._yield)
) {
if (isStatement && !optionalId && !this.match(tt.name)) {
this.unexpected();
}
@@ -1002,8 +994,8 @@ export default class StatementParser extends ExpressionParser {
this.state.inAsync = isAsync;
this.state.inGenerator = node.generator;
}
if (this.match(tt.name) || this.match(tt._yield)) {
node.id = this.parseBindingIdentifier();
if (this.match(tt.name)) {
node.id = this.parseIdentifier();
}
if (isStatement) {
this.state.inAsync = isAsync;