Skip to content

Commit

Permalink
Address reviewed points
Browse files Browse the repository at this point in the history
  • Loading branch information
sosukesuzuki committed Jan 10, 2021
1 parent 9082ef6 commit 6e69209
Show file tree
Hide file tree
Showing 7 changed files with 187 additions and 23 deletions.
8 changes: 1 addition & 7 deletions packages/babel-parser/src/parser/expression.js
Expand Up @@ -537,13 +537,7 @@ export default class ExpressionParser extends LValParser {
const startsExpr = this.hasPlugin("v8intrinsic")
? this.state.type.startsExpr
: this.state.type.startsExpr && !this.match(tt.modulo);
if (
isAwait &&
startsExpr &&
!this.isAmbiguousAwait() &&
(this.scope.inFunction ||
(this.hasPlugin("topLevelAwait") && !this.inModule))
) {
if (isAwait && startsExpr && !this.isAmbiguousAwait()) {
this.raise(
startPos,
this.hasPlugin("topLevelAwait")
Expand Down

This file was deleted.

@@ -0,0 +1,58 @@
{
"type": "File",
"start":0,"end":26,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":26}},
"errors": [
"SyntaxError: 'await' is only allowed within async functions (1:11)",
"SyntaxError: await is not allowed in async function parameters (1:11)"
],
"program": {
"type": "Program",
"start":0,"end":26,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":26}},
"sourceType": "script",
"interpreter": null,
"body": [
{
"type": "ExpressionStatement",
"start":0,"end":26,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":26}},
"expression": {
"type": "ArrowFunctionExpression",
"start":0,"end":25,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":25}},
"id": null,
"generator": false,
"async": true,
"params": [
{
"type": "AssignmentPattern",
"start":7,"end":18,"loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":18}},
"left": {
"type": "Identifier",
"start":7,"end":8,"loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":8},"identifierName":"x"},
"name": "x"
},
"right": {
"type": "AwaitExpression",
"start":11,"end":18,"loc":{"start":{"line":1,"column":11},"end":{"line":1,"column":18}},
"argument": {
"type": "NumericLiteral",
"start":17,"end":18,"loc":{"start":{"line":1,"column":17},"end":{"line":1,"column":18}},
"extra": {
"rawValue": 2,
"raw": "2"
},
"value": 2
}
}
}
],
"body": {
"type": "BlockStatement",
"start":23,"end":25,"loc":{"start":{"line":1,"column":23},"end":{"line":1,"column":25}},
"body": [],
"directives": []
}
}
}
],
"directives": []
}
}
@@ -1,8 +1,4 @@
{
"plugins": [
"topLevelAwait",
"classProperties"
],
"sourceType": "module",
"throws": "Unexpected token, expected \";\" (2:12)"
}
"plugins": ["topLevelAwati", "classProperties"],
"sourceType": "module"
}
@@ -0,0 +1,63 @@
{
"type": "File",
"start":0,"end":33,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
"errors": [
"SyntaxError: 'await' is only allowed within async functions (2:6)",
"SyntaxError: 'await' is only allowed within async functions (2:6)"
],
"program": {
"type": "Program",
"start":0,"end":33,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
"sourceType": "module",
"interpreter": null,
"body": [
{
"type": "ExportNamedDeclaration",
"start":0,"end":33,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
"specifiers": [],
"source": null,
"declaration": {
"type": "ClassDeclaration",
"start":7,"end":33,"loc":{"start":{"line":1,"column":7},"end":{"line":3,"column":1}},
"id": {
"type": "Identifier",
"start":13,"end":14,"loc":{"start":{"line":1,"column":13},"end":{"line":1,"column":14},"identifierName":"C"},
"name": "C"
},
"superClass": null,
"body": {
"type": "ClassBody",
"start":15,"end":33,"loc":{"start":{"line":1,"column":15},"end":{"line":3,"column":1}},
"body": [
{
"type": "ClassProperty",
"start":19,"end":31,"loc":{"start":{"line":2,"column":2},"end":{"line":2,"column":14}},
"static": false,
"key": {
"type": "Identifier",
"start":19,"end":20,"loc":{"start":{"line":2,"column":2},"end":{"line":2,"column":3},"identifierName":"p"},
"name": "p"
},
"computed": false,
"value": {
"type": "AwaitExpression",
"start":23,"end":30,"loc":{"start":{"line":2,"column":6},"end":{"line":2,"column":13}},
"argument": {
"type": "NumericLiteral",
"start":29,"end":30,"loc":{"start":{"line":2,"column":12},"end":{"line":2,"column":13}},
"extra": {
"rawValue": 0,
"raw": "0"
},
"value": 0
}
}
}
]
}
}
}
],
"directives": []
}
}
@@ -1,8 +1,4 @@
{
"sourceType": "module",
"plugins": [
"typescript",
"topLevelAwait"
],
"throws": "Unexpected token, expected \";\" (2:20)"
}
"plugins": ["typescript", "topLevelAwait"]
}
@@ -0,0 +1,60 @@
{
"type": "File",
"start":0,"end":39,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
"errors": [
"SyntaxError: 'await' is only allowed within async functions and at the top levels of modules (2:14)"
],
"program": {
"type": "Program",
"start":0,"end":39,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
"sourceType": "module",
"interpreter": null,
"body": [
{
"type": "TSModuleDeclaration",
"start":0,"end":39,"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":"N"},
"name": "N"
},
"body": {
"type": "TSModuleBlock",
"start":12,"end":39,"loc":{"start":{"line":1,"column":12},"end":{"line":3,"column":1}},
"body": [
{
"type": "VariableDeclaration",
"start":18,"end":37,"loc":{"start":{"line":2,"column":4},"end":{"line":2,"column":23}},
"declarations": [
{
"type": "VariableDeclarator",
"start":24,"end":36,"loc":{"start":{"line":2,"column":10},"end":{"line":2,"column":22}},
"id": {
"type": "Identifier",
"start":24,"end":25,"loc":{"start":{"line":2,"column":10},"end":{"line":2,"column":11},"identifierName":"x"},
"name": "x"
},
"init": {
"type": "AwaitExpression",
"start":28,"end":36,"loc":{"start":{"line":2,"column":14},"end":{"line":2,"column":22}},
"argument": {
"type": "NumericLiteral",
"start":34,"end":36,"loc":{"start":{"line":2,"column":20},"end":{"line":2,"column":22}},
"extra": {
"rawValue": 42,
"raw": "42"
},
"value": 42
}
}
}
],
"kind": "const"
}
]
}
}
],
"directives": []
}
}

0 comments on commit 6e69209

Please sign in to comment.