Skip to content

Commit

Permalink
this.inModule is true in module blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
sosukesuzuki committed Dec 11, 2020
1 parent 1640f64 commit aebc37b
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/babel-parser/src/parser/expression.js
Expand Up @@ -2646,9 +2646,12 @@ export default class ExpressionParser extends LValParser {
paramFlags |= PARAM_AWAIT;
}
this.prodParam.enter(paramFlags);
const oldInModule = this.inModule;
this.inModule = true;
this.parseBlockOrModuleBlockBody(node.body, undefined, true, tt.braceR);
this.scope.exit();
this.prodParam.exit();
this.inModule = oldInModule;
this.eat(tt.braceR);
this.state.labels = oldLabels;
this.state.exportedIdentifiers = oldExportedIdentifiers;
Expand Down
@@ -0,0 +1 @@
module { await: 3 };
@@ -0,0 +1,4 @@
{
"sourceType": "script",
"plugins": ["moduleBlocks"]
}
@@ -0,0 +1,48 @@
{
"type": "File",
"start":0,"end":20,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":20}},
"errors": [
"SyntaxError: 'await' is only allowed within async functions (1:9)"
],
"program": {
"type": "Program",
"start":0,"end":20,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":20}},
"sourceType": "script",
"interpreter": null,
"body": [
{
"type": "ExpressionStatement",
"start":0,"end":20,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":20}},
"expression": {
"type": "ModuleExpression",
"start":0,"end":19,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":19}},
"body": [
{
"type": "LabeledStatement",
"start":9,"end":17,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":17}},
"body": {
"type": "ExpressionStatement",
"start":16,"end":17,"loc":{"start":{"line":1,"column":16},"end":{"line":1,"column":17}},
"expression": {
"type": "NumericLiteral",
"start":16,"end":17,"loc":{"start":{"line":1,"column":16},"end":{"line":1,"column":17}},
"extra": {
"rawValue": 3,
"raw": "3"
},
"value": 3
}
},
"label": {
"type": "Identifier",
"start":9,"end":14,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":14},"identifierName":"await"},
"name": "await"
}
}
]
}
}
],
"directives": []
}
}

0 comments on commit aebc37b

Please sign in to comment.