Allow module block to start a member expression (#13573)

* Accept module in primaryExpression

* Add module blocks to primaryExpression

* Fix package.json

* Fix yarn.lock

* Fix yarn.lock

* Remove package.tgz file
This commit is contained in:
Nicholas Eveland 2021-07-19 15:29:23 -06:00 committed by GitHub
parent fa439d6a73
commit 2c6db56696
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 48 additions and 8 deletions

View File

@ -512,13 +512,6 @@ export default class ExpressionParser extends LValParser {
if (!sawUnary) this.checkExponentialAfterUnary(expr); if (!sawUnary) this.checkExponentialAfterUnary(expr);
return expr; return expr;
} }
if (
this.isContextual("module") &&
this.lookaheadCharCode() === charCodes.leftCurlyBrace &&
!this.hasFollowingLineBreak()
) {
return this.parseModuleExpression();
}
const update = this.match(tt.incDec); const update = this.match(tt.incDec);
const node = this.startNode(); const node = this.startNode();
if (this.state.type.prefix) { if (this.state.type.prefix) {
@ -1002,6 +995,13 @@ export default class ExpressionParser extends LValParser {
return this.finishNode(node, "ThisExpression"); return this.finishNode(node, "ThisExpression");
case tt.name: { case tt.name: {
if (
this.isContextual("module") &&
this.lookaheadCharCode() === charCodes.leftCurlyBrace &&
!this.hasFollowingLineBreak()
) {
return this.parseModuleExpression();
}
const canBeArrow = this.state.potentialArrowAt === this.state.start; const canBeArrow = this.state.potentialArrowAt === this.state.start;
const containsEsc = this.state.containsEsc; const containsEsc = this.state.containsEsc;
const id = this.parseIdentifier(); const id = this.parseIdentifier();

View File

@ -0,0 +1,39 @@
{
"type": "File",
"start":0,"end":13,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":13}},
"program": {
"type": "Program",
"start":0,"end":13,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":13}},
"sourceType": "module",
"interpreter": null,
"body": [
{
"type": "ExpressionStatement",
"start":0,"end":13,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":13}},
"expression": {
"type": "MemberExpression",
"start":0,"end":13,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":13}},
"object": {
"type": "ModuleExpression",
"start":0,"end":9,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":9}},
"body": {
"type": "Program",
"start":8,"end":9,"loc":{"start":{"line":1,"column":8},"end":{"line":1,"column":9}},
"sourceType": "module",
"interpreter": null,
"body": [],
"directives": []
}
},
"computed": false,
"property": {
"type": "Identifier",
"start":10,"end":13,"loc":{"start":{"line":1,"column":10},"end":{"line":1,"column":13},"identifierName":"foo"},
"name": "foo"
}
}
}
],
"directives": []
}
}