Fix parsing yield with dynamicImport (#383)

This commit is contained in:
Brian Ng
2017-02-28 11:43:34 -06:00
committed by Henry Zhu
parent cd133ff8e1
commit 09bb9bc6be
4 changed files with 181 additions and 3 deletions

View File

@@ -61,7 +61,7 @@ pp.getExpression = function() {
// the AST node that the inner parser gave them in another node.
// Parse a full expression. The optional arguments are used to
// forbid the `in` operator (in for loops initalization expressions)
// forbid the `in` operator (in for loops initialization expressions)
// and provide reference for storing '=' operator inside shorthand
// property assignment in contexts where both object expression
// and object pattern might appear (so it's possible to raise
@@ -1095,7 +1095,11 @@ pp.parseAwait = function (node) {
pp.parseYield = function () {
const node = this.startNode();
this.next();
if (this.match(tt.semi) || this.canInsertSemicolon() || (!this.match(tt.star) && !this.state.type.startsExpr)) {
if (
this.match(tt.semi) ||
this.canInsertSemicolon() ||
(!this.match(tt.star) && !this.state.type.startsExpr)
) {
node.delegate = false;
node.argument = null;
} else {

View File

@@ -143,7 +143,7 @@ export const keywords = {
"class": new KeywordTokenType("class"),
"extends": new KeywordTokenType("extends", { beforeExpr }),
"export": new KeywordTokenType("export"),
"import": new KeywordTokenType("import"),
"import": new KeywordTokenType("import", { startsExpr }),
"yield": new KeywordTokenType("yield", { beforeExpr, startsExpr }),
"null": new KeywordTokenType("null", { startsExpr }),
"true": new KeywordTokenType("true", { startsExpr }),