Fix parsing yield with dynamicImport (#383)
This commit is contained in:
parent
cd133ff8e1
commit
09bb9bc6be
@ -61,7 +61,7 @@ pp.getExpression = function() {
|
|||||||
// the AST node that the inner parser gave them in another node.
|
// the AST node that the inner parser gave them in another node.
|
||||||
|
|
||||||
// Parse a full expression. The optional arguments are used to
|
// 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
|
// and provide reference for storing '=' operator inside shorthand
|
||||||
// property assignment in contexts where both object expression
|
// property assignment in contexts where both object expression
|
||||||
// and object pattern might appear (so it's possible to raise
|
// and object pattern might appear (so it's possible to raise
|
||||||
@ -1095,7 +1095,11 @@ pp.parseAwait = function (node) {
|
|||||||
pp.parseYield = function () {
|
pp.parseYield = function () {
|
||||||
const node = this.startNode();
|
const node = this.startNode();
|
||||||
this.next();
|
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.delegate = false;
|
||||||
node.argument = null;
|
node.argument = null;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -143,7 +143,7 @@ export const keywords = {
|
|||||||
"class": new KeywordTokenType("class"),
|
"class": new KeywordTokenType("class"),
|
||||||
"extends": new KeywordTokenType("extends", { beforeExpr }),
|
"extends": new KeywordTokenType("extends", { beforeExpr }),
|
||||||
"export": new KeywordTokenType("export"),
|
"export": new KeywordTokenType("export"),
|
||||||
"import": new KeywordTokenType("import"),
|
"import": new KeywordTokenType("import", { startsExpr }),
|
||||||
"yield": new KeywordTokenType("yield", { beforeExpr, startsExpr }),
|
"yield": new KeywordTokenType("yield", { beforeExpr, startsExpr }),
|
||||||
"null": new KeywordTokenType("null", { startsExpr }),
|
"null": new KeywordTokenType("null", { startsExpr }),
|
||||||
"true": new KeywordTokenType("true", { startsExpr }),
|
"true": new KeywordTokenType("true", { startsExpr }),
|
||||||
|
|||||||
3
test/fixtures/experimental/dynamic-import/generator/actual.js
vendored
Normal file
3
test/fixtures/experimental/dynamic-import/generator/actual.js
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
function* a() {
|
||||||
|
yield import('http');
|
||||||
|
}
|
||||||
171
test/fixtures/experimental/dynamic-import/generator/expected.json
vendored
Normal file
171
test/fixtures/experimental/dynamic-import/generator/expected.json
vendored
Normal file
@ -0,0 +1,171 @@
|
|||||||
|
{
|
||||||
|
"type": "File",
|
||||||
|
"start": 0,
|
||||||
|
"end": 41,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 3,
|
||||||
|
"column": 1
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"program": {
|
||||||
|
"type": "Program",
|
||||||
|
"start": 0,
|
||||||
|
"end": 41,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 3,
|
||||||
|
"column": 1
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"sourceType": "script",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "FunctionDeclaration",
|
||||||
|
"start": 0,
|
||||||
|
"end": 41,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 3,
|
||||||
|
"column": 1
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"id": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start": 10,
|
||||||
|
"end": 11,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 10
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 11
|
||||||
|
},
|
||||||
|
"identifierName": "a"
|
||||||
|
},
|
||||||
|
"name": "a"
|
||||||
|
},
|
||||||
|
"generator": true,
|
||||||
|
"expression": false,
|
||||||
|
"async": false,
|
||||||
|
"params": [],
|
||||||
|
"body": {
|
||||||
|
"type": "BlockStatement",
|
||||||
|
"start": 14,
|
||||||
|
"end": 41,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 14
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 3,
|
||||||
|
"column": 1
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"start": 18,
|
||||||
|
"end": 39,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 2,
|
||||||
|
"column": 2
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 2,
|
||||||
|
"column": 23
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"expression": {
|
||||||
|
"type": "YieldExpression",
|
||||||
|
"start": 18,
|
||||||
|
"end": 38,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 2,
|
||||||
|
"column": 2
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 2,
|
||||||
|
"column": 22
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"delegate": false,
|
||||||
|
"argument": {
|
||||||
|
"type": "CallExpression",
|
||||||
|
"start": 24,
|
||||||
|
"end": 38,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 2,
|
||||||
|
"column": 8
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 2,
|
||||||
|
"column": 22
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"callee": {
|
||||||
|
"type": "Import",
|
||||||
|
"start": 24,
|
||||||
|
"end": 30,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 2,
|
||||||
|
"column": 8
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 2,
|
||||||
|
"column": 14
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"arguments": [
|
||||||
|
{
|
||||||
|
"type": "StringLiteral",
|
||||||
|
"start": 31,
|
||||||
|
"end": 37,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 2,
|
||||||
|
"column": 15
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 2,
|
||||||
|
"column": 21
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"extra": {
|
||||||
|
"rawValue": "http",
|
||||||
|
"raw": "'http'"
|
||||||
|
},
|
||||||
|
"value": "http"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"directives": []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"directives": []
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user