From bb3722c0d77585a990e62cd59f8d70165bc60b5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hu=C3=A1ng=20J=C3=B9nli=C3=A0ng?= Date: Fri, 16 Jul 2021 10:35:19 -0400 Subject: [PATCH] Fix await binding error within static block (#13088) * fix: allow await within SCOPE_FUNCTION under static block * perf: scan scopeStack for once * add new test case * chore: update allowlist --- .../babel-parser/src/parser/expression.js | 2 +- packages/babel-parser/src/util/scope.js | 11 +- .../input.js | 3 + .../output.json | 100 ++ .../input.js | 7 + .../output.json | 251 +++++ .../input.js | 2 + .../output.json | 85 +- .../input.js | 3 + .../options.json | 6 + .../output.json | 94 ++ .../await-binding-in-static-block/input.js | 30 +- .../options.json | 3 + .../await-binding-in-static-block/output.json | 876 ++++++++++-------- scripts/parser-tests/test262/allowlist.txt | 18 - 15 files changed, 1091 insertions(+), 400 deletions(-) create mode 100644 packages/babel-parser/test/fixtures/experimental/class-static-block/await-binding-in-arrow-function-in-static-block copy/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/class-static-block/await-binding-in-arrow-function-in-static-block copy/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/class-static-block/await-binding-in-async-arrow-function-in-static-block/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/class-static-block/await-binding-in-async-arrow-function-in-static-block/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/class-static-block/await-binding-in-initializer-in-static-block/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/class-static-block/await-binding-in-initializer-in-static-block/options.json create mode 100644 packages/babel-parser/test/fixtures/experimental/class-static-block/await-binding-in-initializer-in-static-block/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/class-static-block/await-binding-in-static-block/options.json diff --git a/packages/babel-parser/src/parser/expression.js b/packages/babel-parser/src/parser/expression.js index 82b531ff42a8..854e64e03b6c 100644 --- a/packages/babel-parser/src/parser/expression.js +++ b/packages/babel-parser/src/parser/expression.js @@ -2385,7 +2385,7 @@ export default class ExpressionParser extends LValParser { if (this.prodParam.hasAwait) { this.raise(startLoc, Errors.AwaitBindingIdentifier); return; - } else if (this.scope.inStaticBlock && !this.scope.inNonArrowFunction) { + } else if (this.scope.inStaticBlock) { this.raise(startLoc, Errors.AwaitBindingIdentifierInStaticBlock); return; } else { diff --git a/packages/babel-parser/src/util/scope.js b/packages/babel-parser/src/util/scope.js index 235ab5c9dbcb..d28d4587f91e 100644 --- a/packages/babel-parser/src/util/scope.js +++ b/packages/babel-parser/src/util/scope.js @@ -65,7 +65,16 @@ export default class ScopeHandler { return (flags & SCOPE_CLASS) > 0 && (flags & SCOPE_FUNCTION) === 0; } get inStaticBlock() { - return (this.currentThisScopeFlags() & SCOPE_STATIC_BLOCK) > 0; + for (let i = this.scopeStack.length - 1; ; i--) { + const { flags } = this.scopeStack[i]; + if (flags & SCOPE_STATIC_BLOCK) { + return true; + } + if (flags & (SCOPE_VAR | SCOPE_CLASS)) { + // function body, module body, class property initializers + return false; + } + } } get inNonArrowFunction() { return (this.currentThisScopeFlags() & SCOPE_FUNCTION) > 0; diff --git a/packages/babel-parser/test/fixtures/experimental/class-static-block/await-binding-in-arrow-function-in-static-block copy/input.js b/packages/babel-parser/test/fixtures/experimental/class-static-block/await-binding-in-arrow-function-in-static-block copy/input.js new file mode 100644 index 000000000000..9369db77fcd5 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/class-static-block/await-binding-in-arrow-function-in-static-block copy/input.js @@ -0,0 +1,3 @@ +var C; +// await in body is allowed +C = class { static { () => await } }; diff --git a/packages/babel-parser/test/fixtures/experimental/class-static-block/await-binding-in-arrow-function-in-static-block copy/output.json b/packages/babel-parser/test/fixtures/experimental/class-static-block/await-binding-in-arrow-function-in-static-block copy/output.json new file mode 100644 index 000000000000..b6b10678a826 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/class-static-block/await-binding-in-arrow-function-in-static-block copy/output.json @@ -0,0 +1,100 @@ +{ + "type": "File", + "start":0,"end":72,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":37}}, + "program": { + "type": "Program", + "start":0,"end":72,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":37}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start":0,"end":6,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":6}}, + "trailingComments": [ + { + "type": "CommentLine", + "value": " await in body is allowed", + "start":7,"end":34,"loc":{"start":{"line":2,"column":0},"end":{"line":2,"column":27}} + } + ], + "declarations": [ + { + "type": "VariableDeclarator", + "start":4,"end":5,"loc":{"start":{"line":1,"column":4},"end":{"line":1,"column":5}}, + "id": { + "type": "Identifier", + "start":4,"end":5,"loc":{"start":{"line":1,"column":4},"end":{"line":1,"column":5},"identifierName":"C"}, + "name": "C" + }, + "init": null + } + ], + "kind": "var" + }, + { + "type": "ExpressionStatement", + "start":35,"end":72,"loc":{"start":{"line":3,"column":0},"end":{"line":3,"column":37}}, + "leadingComments": [ + { + "type": "CommentLine", + "value": " await in body is allowed", + "start":7,"end":34,"loc":{"start":{"line":2,"column":0},"end":{"line":2,"column":27}} + } + ], + "expression": { + "type": "AssignmentExpression", + "start":35,"end":71,"loc":{"start":{"line":3,"column":0},"end":{"line":3,"column":36}}, + "operator": "=", + "left": { + "type": "Identifier", + "start":35,"end":36,"loc":{"start":{"line":3,"column":0},"end":{"line":3,"column":1},"identifierName":"C"}, + "name": "C" + }, + "right": { + "type": "ClassExpression", + "start":39,"end":71,"loc":{"start":{"line":3,"column":4},"end":{"line":3,"column":36}}, + "id": null, + "superClass": null, + "body": { + "type": "ClassBody", + "start":45,"end":71,"loc":{"start":{"line":3,"column":10},"end":{"line":3,"column":36}}, + "body": [ + { + "type": "StaticBlock", + "start":47,"end":69,"loc":{"start":{"line":3,"column":12},"end":{"line":3,"column":34}}, + "body": [ + { + "type": "ExpressionStatement", + "start":56,"end":67,"loc":{"start":{"line":3,"column":21},"end":{"line":3,"column":32}}, + "expression": { + "type": "ArrowFunctionExpression", + "start":56,"end":67,"loc":{"start":{"line":3,"column":21},"end":{"line":3,"column":32}}, + "id": null, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "Identifier", + "start":62,"end":67,"loc":{"start":{"line":3,"column":27},"end":{"line":3,"column":32},"identifierName":"await"}, + "name": "await" + } + } + } + ] + } + ] + } + } + } + } + ], + "directives": [] + }, + "comments": [ + { + "type": "CommentLine", + "value": " await in body is allowed", + "start":7,"end":34,"loc":{"start":{"line":2,"column":0},"end":{"line":2,"column":27}} + } + ] +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/class-static-block/await-binding-in-async-arrow-function-in-static-block/input.js b/packages/babel-parser/test/fixtures/experimental/class-static-block/await-binding-in-async-arrow-function-in-static-block/input.js new file mode 100644 index 000000000000..6487e826d9ba --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/class-static-block/await-binding-in-async-arrow-function-in-static-block/input.js @@ -0,0 +1,7 @@ +var C; +// await is not allowed in async arrow +C = class { static { async (await) => {} } }; + +C = class { static { async (x = await) => {} } }; + +C = class { static { async ({ [await]: x }) => {} } }; diff --git a/packages/babel-parser/test/fixtures/experimental/class-static-block/await-binding-in-async-arrow-function-in-static-block/output.json b/packages/babel-parser/test/fixtures/experimental/class-static-block/await-binding-in-async-arrow-function-in-static-block/output.json new file mode 100644 index 000000000000..ec2e6a8f510b --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/class-static-block/await-binding-in-async-arrow-function-in-static-block/output.json @@ -0,0 +1,251 @@ +{ + "type": "File", + "start":0,"end":198,"loc":{"start":{"line":1,"column":0},"end":{"line":7,"column":54}}, + "errors": [ + "SyntaxError: Can not use 'await' as identifier inside a static block. (3:28)", + "SyntaxError: Can not use 'await' as identifier inside a static block. (5:32)", + "SyntaxError: Can not use 'await' as identifier inside a static block. (7:31)" + ], + "program": { + "type": "Program", + "start":0,"end":198,"loc":{"start":{"line":1,"column":0},"end":{"line":7,"column":54}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start":0,"end":6,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":6}}, + "trailingComments": [ + { + "type": "CommentLine", + "value": " await is not allowed in async arrow", + "start":7,"end":45,"loc":{"start":{"line":2,"column":0},"end":{"line":2,"column":38}} + } + ], + "declarations": [ + { + "type": "VariableDeclarator", + "start":4,"end":5,"loc":{"start":{"line":1,"column":4},"end":{"line":1,"column":5}}, + "id": { + "type": "Identifier", + "start":4,"end":5,"loc":{"start":{"line":1,"column":4},"end":{"line":1,"column":5},"identifierName":"C"}, + "name": "C" + }, + "init": null + } + ], + "kind": "var" + }, + { + "type": "ExpressionStatement", + "start":46,"end":91,"loc":{"start":{"line":3,"column":0},"end":{"line":3,"column":45}}, + "leadingComments": [ + { + "type": "CommentLine", + "value": " await is not allowed in async arrow", + "start":7,"end":45,"loc":{"start":{"line":2,"column":0},"end":{"line":2,"column":38}} + } + ], + "expression": { + "type": "AssignmentExpression", + "start":46,"end":90,"loc":{"start":{"line":3,"column":0},"end":{"line":3,"column":44}}, + "operator": "=", + "left": { + "type": "Identifier", + "start":46,"end":47,"loc":{"start":{"line":3,"column":0},"end":{"line":3,"column":1},"identifierName":"C"}, + "name": "C" + }, + "right": { + "type": "ClassExpression", + "start":50,"end":90,"loc":{"start":{"line":3,"column":4},"end":{"line":3,"column":44}}, + "id": null, + "superClass": null, + "body": { + "type": "ClassBody", + "start":56,"end":90,"loc":{"start":{"line":3,"column":10},"end":{"line":3,"column":44}}, + "body": [ + { + "type": "StaticBlock", + "start":58,"end":88,"loc":{"start":{"line":3,"column":12},"end":{"line":3,"column":42}}, + "body": [ + { + "type": "ExpressionStatement", + "start":67,"end":86,"loc":{"start":{"line":3,"column":21},"end":{"line":3,"column":40}}, + "expression": { + "type": "ArrowFunctionExpression", + "start":67,"end":86,"loc":{"start":{"line":3,"column":21},"end":{"line":3,"column":40}}, + "id": null, + "generator": false, + "async": true, + "params": [ + { + "type": "Identifier", + "start":74,"end":79,"loc":{"start":{"line":3,"column":28},"end":{"line":3,"column":33},"identifierName":"await"}, + "name": "await" + } + ], + "body": { + "type": "BlockStatement", + "start":84,"end":86,"loc":{"start":{"line":3,"column":38},"end":{"line":3,"column":40}}, + "body": [], + "directives": [] + } + } + } + ] + } + ] + } + } + } + }, + { + "type": "ExpressionStatement", + "start":93,"end":142,"loc":{"start":{"line":5,"column":0},"end":{"line":5,"column":49}}, + "expression": { + "type": "AssignmentExpression", + "start":93,"end":141,"loc":{"start":{"line":5,"column":0},"end":{"line":5,"column":48}}, + "operator": "=", + "left": { + "type": "Identifier", + "start":93,"end":94,"loc":{"start":{"line":5,"column":0},"end":{"line":5,"column":1},"identifierName":"C"}, + "name": "C" + }, + "right": { + "type": "ClassExpression", + "start":97,"end":141,"loc":{"start":{"line":5,"column":4},"end":{"line":5,"column":48}}, + "id": null, + "superClass": null, + "body": { + "type": "ClassBody", + "start":103,"end":141,"loc":{"start":{"line":5,"column":10},"end":{"line":5,"column":48}}, + "body": [ + { + "type": "StaticBlock", + "start":105,"end":139,"loc":{"start":{"line":5,"column":12},"end":{"line":5,"column":46}}, + "body": [ + { + "type": "ExpressionStatement", + "start":114,"end":137,"loc":{"start":{"line":5,"column":21},"end":{"line":5,"column":44}}, + "expression": { + "type": "ArrowFunctionExpression", + "start":114,"end":137,"loc":{"start":{"line":5,"column":21},"end":{"line":5,"column":44}}, + "id": null, + "generator": false, + "async": true, + "params": [ + { + "type": "AssignmentPattern", + "start":121,"end":130,"loc":{"start":{"line":5,"column":28},"end":{"line":5,"column":37}}, + "left": { + "type": "Identifier", + "start":121,"end":122,"loc":{"start":{"line":5,"column":28},"end":{"line":5,"column":29},"identifierName":"x"}, + "name": "x" + }, + "right": { + "type": "Identifier", + "start":125,"end":130,"loc":{"start":{"line":5,"column":32},"end":{"line":5,"column":37},"identifierName":"await"}, + "name": "await" + } + } + ], + "body": { + "type": "BlockStatement", + "start":135,"end":137,"loc":{"start":{"line":5,"column":42},"end":{"line":5,"column":44}}, + "body": [], + "directives": [] + } + } + } + ] + } + ] + } + } + } + }, + { + "type": "ExpressionStatement", + "start":144,"end":198,"loc":{"start":{"line":7,"column":0},"end":{"line":7,"column":54}}, + "expression": { + "type": "AssignmentExpression", + "start":144,"end":197,"loc":{"start":{"line":7,"column":0},"end":{"line":7,"column":53}}, + "operator": "=", + "left": { + "type": "Identifier", + "start":144,"end":145,"loc":{"start":{"line":7,"column":0},"end":{"line":7,"column":1},"identifierName":"C"}, + "name": "C" + }, + "right": { + "type": "ClassExpression", + "start":148,"end":197,"loc":{"start":{"line":7,"column":4},"end":{"line":7,"column":53}}, + "id": null, + "superClass": null, + "body": { + "type": "ClassBody", + "start":154,"end":197,"loc":{"start":{"line":7,"column":10},"end":{"line":7,"column":53}}, + "body": [ + { + "type": "StaticBlock", + "start":156,"end":195,"loc":{"start":{"line":7,"column":12},"end":{"line":7,"column":51}}, + "body": [ + { + "type": "ExpressionStatement", + "start":165,"end":193,"loc":{"start":{"line":7,"column":21},"end":{"line":7,"column":49}}, + "expression": { + "type": "ArrowFunctionExpression", + "start":165,"end":193,"loc":{"start":{"line":7,"column":21},"end":{"line":7,"column":49}}, + "id": null, + "generator": false, + "async": true, + "params": [ + { + "type": "ObjectPattern", + "start":172,"end":186,"loc":{"start":{"line":7,"column":28},"end":{"line":7,"column":42}}, + "properties": [ + { + "type": "ObjectProperty", + "start":174,"end":184,"loc":{"start":{"line":7,"column":30},"end":{"line":7,"column":40}}, + "method": false, + "computed": true, + "key": { + "type": "Identifier", + "start":175,"end":180,"loc":{"start":{"line":7,"column":31},"end":{"line":7,"column":36},"identifierName":"await"}, + "name": "await" + }, + "shorthand": false, + "value": { + "type": "Identifier", + "start":183,"end":184,"loc":{"start":{"line":7,"column":39},"end":{"line":7,"column":40},"identifierName":"x"}, + "name": "x" + } + } + ] + } + ], + "body": { + "type": "BlockStatement", + "start":191,"end":193,"loc":{"start":{"line":7,"column":47},"end":{"line":7,"column":49}}, + "body": [], + "directives": [] + } + } + } + ] + } + ] + } + } + } + } + ], + "directives": [] + }, + "comments": [ + { + "type": "CommentLine", + "value": " await is not allowed in async arrow", + "start":7,"end":45,"loc":{"start":{"line":2,"column":0},"end":{"line":2,"column":38}} + } + ] +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/class-static-block/await-binding-in-function-in-static-block/input.js b/packages/babel-parser/test/fixtures/experimental/class-static-block/await-binding-in-function-in-static-block/input.js index d35f8544e20c..f269b0c0920e 100644 --- a/packages/babel-parser/test/fixtures/experimental/class-static-block/await-binding-in-function-in-static-block/input.js +++ b/packages/babel-parser/test/fixtures/experimental/class-static-block/await-binding-in-function-in-static-block/input.js @@ -7,3 +7,5 @@ C = class { static { function f(await) {} } }; C = class { static { function f(x = await) {} } }; C = class { static { function f({ [await]: x }) {} } }; +// await in function expression is allowed +C = class { static { (function await() {}) } }; diff --git a/packages/babel-parser/test/fixtures/experimental/class-static-block/await-binding-in-function-in-static-block/output.json b/packages/babel-parser/test/fixtures/experimental/class-static-block/await-binding-in-function-in-static-block/output.json index 8468c2f86fdd..c0b1913d155f 100644 --- a/packages/babel-parser/test/fixtures/experimental/class-static-block/await-binding-in-function-in-static-block/output.json +++ b/packages/babel-parser/test/fixtures/experimental/class-static-block/await-binding-in-function-in-static-block/output.json @@ -1,9 +1,9 @@ { "type": "File", - "start":0,"end":213,"loc":{"start":{"line":1,"column":0},"end":{"line":9,"column":55}}, + "start":0,"end":304,"loc":{"start":{"line":1,"column":0},"end":{"line":11,"column":47}}, "program": { "type": "Program", - "start":0,"end":213,"loc":{"start":{"line":1,"column":0},"end":{"line":9,"column":55}}, + "start":0,"end":304,"loc":{"start":{"line":1,"column":0},"end":{"line":11,"column":47}}, "sourceType": "script", "interpreter": null, "body": [ @@ -208,6 +208,13 @@ { "type": "ExpressionStatement", "start":158,"end":213,"loc":{"start":{"line":9,"column":0},"end":{"line":9,"column":55}}, + "trailingComments": [ + { + "type": "CommentLine", + "value": " await in function expression is allowed", + "start":214,"end":256,"loc":{"start":{"line":10,"column":0},"end":{"line":10,"column":42}} + } + ], "expression": { "type": "AssignmentExpression", "start":158,"end":212,"loc":{"start":{"line":9,"column":0},"end":{"line":9,"column":54}}, @@ -278,8 +285,80 @@ } } } + }, + { + "type": "ExpressionStatement", + "start":257,"end":304,"loc":{"start":{"line":11,"column":0},"end":{"line":11,"column":47}}, + "leadingComments": [ + { + "type": "CommentLine", + "value": " await in function expression is allowed", + "start":214,"end":256,"loc":{"start":{"line":10,"column":0},"end":{"line":10,"column":42}} + } + ], + "expression": { + "type": "AssignmentExpression", + "start":257,"end":303,"loc":{"start":{"line":11,"column":0},"end":{"line":11,"column":46}}, + "operator": "=", + "left": { + "type": "Identifier", + "start":257,"end":258,"loc":{"start":{"line":11,"column":0},"end":{"line":11,"column":1},"identifierName":"C"}, + "name": "C" + }, + "right": { + "type": "ClassExpression", + "start":261,"end":303,"loc":{"start":{"line":11,"column":4},"end":{"line":11,"column":46}}, + "id": null, + "superClass": null, + "body": { + "type": "ClassBody", + "start":267,"end":303,"loc":{"start":{"line":11,"column":10},"end":{"line":11,"column":46}}, + "body": [ + { + "type": "StaticBlock", + "start":269,"end":301,"loc":{"start":{"line":11,"column":12},"end":{"line":11,"column":44}}, + "body": [ + { + "type": "ExpressionStatement", + "start":278,"end":299,"loc":{"start":{"line":11,"column":21},"end":{"line":11,"column":42}}, + "expression": { + "type": "FunctionExpression", + "start":279,"end":298,"loc":{"start":{"line":11,"column":22},"end":{"line":11,"column":41}}, + "extra": { + "parenthesized": true, + "parenStart": 278 + }, + "id": { + "type": "Identifier", + "start":288,"end":293,"loc":{"start":{"line":11,"column":31},"end":{"line":11,"column":36},"identifierName":"await"}, + "name": "await" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start":296,"end":298,"loc":{"start":{"line":11,"column":39},"end":{"line":11,"column":41}}, + "body": [], + "directives": [] + } + } + } + ] + } + ] + } + } + } } ], "directives": [] - } + }, + "comments": [ + { + "type": "CommentLine", + "value": " await in function expression is allowed", + "start":214,"end":256,"loc":{"start":{"line":10,"column":0},"end":{"line":10,"column":42}} + } + ] } \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/class-static-block/await-binding-in-initializer-in-static-block/input.js b/packages/babel-parser/test/fixtures/experimental/class-static-block/await-binding-in-initializer-in-static-block/input.js new file mode 100644 index 000000000000..bed6eababd56 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/class-static-block/await-binding-in-initializer-in-static-block/input.js @@ -0,0 +1,3 @@ +var C; + +C = class { static { class D { x = await } } }; diff --git a/packages/babel-parser/test/fixtures/experimental/class-static-block/await-binding-in-initializer-in-static-block/options.json b/packages/babel-parser/test/fixtures/experimental/class-static-block/await-binding-in-initializer-in-static-block/options.json new file mode 100644 index 000000000000..f12f46a4196c --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/class-static-block/await-binding-in-initializer-in-static-block/options.json @@ -0,0 +1,6 @@ +{ + "plugins": [ + "classStaticBlock", + "classProperties" + ] +} diff --git a/packages/babel-parser/test/fixtures/experimental/class-static-block/await-binding-in-initializer-in-static-block/output.json b/packages/babel-parser/test/fixtures/experimental/class-static-block/await-binding-in-initializer-in-static-block/output.json new file mode 100644 index 000000000000..77baeecac2fe --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/class-static-block/await-binding-in-initializer-in-static-block/output.json @@ -0,0 +1,94 @@ +{ + "type": "File", + "start":0,"end":55,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":47}}, + "program": { + "type": "Program", + "start":0,"end":55,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":47}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start":0,"end":6,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":6}}, + "declarations": [ + { + "type": "VariableDeclarator", + "start":4,"end":5,"loc":{"start":{"line":1,"column":4},"end":{"line":1,"column":5}}, + "id": { + "type": "Identifier", + "start":4,"end":5,"loc":{"start":{"line":1,"column":4},"end":{"line":1,"column":5},"identifierName":"C"}, + "name": "C" + }, + "init": null + } + ], + "kind": "var" + }, + { + "type": "ExpressionStatement", + "start":8,"end":55,"loc":{"start":{"line":3,"column":0},"end":{"line":3,"column":47}}, + "expression": { + "type": "AssignmentExpression", + "start":8,"end":54,"loc":{"start":{"line":3,"column":0},"end":{"line":3,"column":46}}, + "operator": "=", + "left": { + "type": "Identifier", + "start":8,"end":9,"loc":{"start":{"line":3,"column":0},"end":{"line":3,"column":1},"identifierName":"C"}, + "name": "C" + }, + "right": { + "type": "ClassExpression", + "start":12,"end":54,"loc":{"start":{"line":3,"column":4},"end":{"line":3,"column":46}}, + "id": null, + "superClass": null, + "body": { + "type": "ClassBody", + "start":18,"end":54,"loc":{"start":{"line":3,"column":10},"end":{"line":3,"column":46}}, + "body": [ + { + "type": "StaticBlock", + "start":20,"end":52,"loc":{"start":{"line":3,"column":12},"end":{"line":3,"column":44}}, + "body": [ + { + "type": "ClassDeclaration", + "start":29,"end":50,"loc":{"start":{"line":3,"column":21},"end":{"line":3,"column":42}}, + "id": { + "type": "Identifier", + "start":35,"end":36,"loc":{"start":{"line":3,"column":27},"end":{"line":3,"column":28},"identifierName":"D"}, + "name": "D" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start":37,"end":50,"loc":{"start":{"line":3,"column":29},"end":{"line":3,"column":42}}, + "body": [ + { + "type": "ClassProperty", + "start":39,"end":48,"loc":{"start":{"line":3,"column":31},"end":{"line":3,"column":40}}, + "static": false, + "key": { + "type": "Identifier", + "start":39,"end":40,"loc":{"start":{"line":3,"column":31},"end":{"line":3,"column":32},"identifierName":"x"}, + "name": "x" + }, + "computed": false, + "value": { + "type": "Identifier", + "start":43,"end":48,"loc":{"start":{"line":3,"column":35},"end":{"line":3,"column":40},"identifierName":"await"}, + "name": "await" + } + } + ] + } + } + ] + } + ] + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/class-static-block/await-binding-in-static-block/input.js b/packages/babel-parser/test/fixtures/experimental/class-static-block/await-binding-in-static-block/input.js index 1813534f9131..f0eb183be16f 100644 --- a/packages/babel-parser/test/fixtures/experimental/class-static-block/await-binding-in-static-block/input.js +++ b/packages/babel-parser/test/fixtures/experimental/class-static-block/await-binding-in-static-block/input.js @@ -1,27 +1,29 @@ var C; - +// This file enumerates all the disallowed cases, for allowed cases, see await-binding-* C = class { static { await } }; -C = class { static { () => await } }; - -C = class { static { (await) => {} } }; - C = class { static { (await) } }; -C = class { static { async (await) => {} } }; - C = class { static { async (await) } }; -C = class { static { ({ [await]: x}) => {} } }; - -C = class { static { ({ [await]: x}) } }; - -C = class { static { async ({ [await]: x}) => {} } }; - C = class { static { async ({ [await]: x}) } }; async (x = class { static { await } }) => {}; +// await as label is not allowed +C = class { static { await: 0 } }; +C = class { static { class D { [await] } } }; +// await binding in function declaration is not allowed C = class { static { function await() {} } }; +// await binding in class declaration is not allowed +C = class { static { class await {} } }; +// await binding in class expression is not allowed +C = class { static { (class await {}) } }; +// await in arrow parameters is not allowed +C = class { static { (await) => {} } }; -C = class { static { await: 0 } }; +C = class { static { (x = await) => {} } }; + +C = class { static { ({ [await]: x }) => {} } }; + +C = class { static { { await } } }; diff --git a/packages/babel-parser/test/fixtures/experimental/class-static-block/await-binding-in-static-block/options.json b/packages/babel-parser/test/fixtures/experimental/class-static-block/await-binding-in-static-block/options.json new file mode 100644 index 000000000000..3b03f5fe57cd --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/class-static-block/await-binding-in-static-block/options.json @@ -0,0 +1,3 @@ +{ + "plugins": ["classStaticBlock", "classProperties"] +} diff --git a/packages/babel-parser/test/fixtures/experimental/class-static-block/await-binding-in-static-block/output.json b/packages/babel-parser/test/fixtures/experimental/class-static-block/await-binding-in-static-block/output.json index 122d4136db03..ce70f8312e1a 100644 --- a/packages/babel-parser/test/fixtures/experimental/class-static-block/await-binding-in-static-block/output.json +++ b/packages/babel-parser/test/fixtures/experimental/class-static-block/await-binding-in-static-block/output.json @@ -1,30 +1,38 @@ { "type": "File", - "start":0,"end":568,"loc":{"start":{"line":1,"column":0},"end":{"line":27,"column":34}}, + "start":0,"end":921,"loc":{"start":{"line":1,"column":0},"end":{"line":29,"column":35}}, "errors": [ "SyntaxError: Can not use 'await' as identifier inside a static block. (3:21)", - "SyntaxError: Can not use 'await' as identifier inside a static block. (5:27)", - "SyntaxError: Can not use 'await' as identifier inside a static block. (7:22)", - "SyntaxError: Can not use 'await' as identifier inside a static block. (9:22)", + "SyntaxError: Can not use 'await' as identifier inside a static block. (5:22)", + "SyntaxError: Can not use 'await' as identifier inside a static block. (7:28)", + "SyntaxError: Can not use 'await' as identifier inside a static block. (9:31)", "SyntaxError: Can not use 'await' as identifier inside a static block. (11:28)", - "SyntaxError: Can not use 'await' as identifier inside a static block. (13:28)", - "SyntaxError: Can not use 'await' as identifier inside a static block. (15:25)", - "SyntaxError: Can not use 'await' as identifier inside a static block. (17:25)", - "SyntaxError: Can not use 'await' as identifier inside a static block. (19:31)", - "SyntaxError: Can not use 'await' as identifier inside a static block. (21:31)", - "SyntaxError: Can not use 'await' as identifier inside a static block. (23:28)", - "SyntaxError: Can not use 'await' as identifier inside a static block. (25:30)", - "SyntaxError: Can not use 'await' as identifier inside a static block. (27:21)" + "SyntaxError: Can not use 'await' as identifier inside a static block. (13:21)", + "SyntaxError: Can not use 'await' as identifier inside a static block. (15:32)", + "SyntaxError: Can not use 'await' as identifier inside a static block. (17:30)", + "SyntaxError: Can not use 'await' as identifier inside a static block. (19:27)", + "SyntaxError: Can not use 'await' as identifier inside a static block. (21:28)", + "SyntaxError: Can not use 'await' as identifier inside a static block. (23:22)", + "SyntaxError: Can not use 'await' as identifier inside a static block. (25:26)", + "SyntaxError: Can not use 'await' as identifier inside a static block. (27:25)", + "SyntaxError: Can not use 'await' as identifier inside a static block. (29:23)" ], "program": { "type": "Program", - "start":0,"end":568,"loc":{"start":{"line":1,"column":0},"end":{"line":27,"column":34}}, + "start":0,"end":921,"loc":{"start":{"line":1,"column":0},"end":{"line":29,"column":35}}, "sourceType": "script", "interpreter": null, "body": [ { "type": "VariableDeclaration", "start":0,"end":6,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":6}}, + "trailingComments": [ + { + "type": "CommentLine", + "value": " This file enumerates all the disallowed cases, for allowed cases, see await-binding-*", + "start":7,"end":95,"loc":{"start":{"line":2,"column":0},"end":{"line":2,"column":88}} + } + ], "declarations": [ { "type": "VariableDeclarator", @@ -41,35 +49,42 @@ }, { "type": "ExpressionStatement", - "start":8,"end":39,"loc":{"start":{"line":3,"column":0},"end":{"line":3,"column":31}}, + "start":96,"end":127,"loc":{"start":{"line":3,"column":0},"end":{"line":3,"column":31}}, + "leadingComments": [ + { + "type": "CommentLine", + "value": " This file enumerates all the disallowed cases, for allowed cases, see await-binding-*", + "start":7,"end":95,"loc":{"start":{"line":2,"column":0},"end":{"line":2,"column":88}} + } + ], "expression": { "type": "AssignmentExpression", - "start":8,"end":38,"loc":{"start":{"line":3,"column":0},"end":{"line":3,"column":30}}, + "start":96,"end":126,"loc":{"start":{"line":3,"column":0},"end":{"line":3,"column":30}}, "operator": "=", "left": { "type": "Identifier", - "start":8,"end":9,"loc":{"start":{"line":3,"column":0},"end":{"line":3,"column":1},"identifierName":"C"}, + "start":96,"end":97,"loc":{"start":{"line":3,"column":0},"end":{"line":3,"column":1},"identifierName":"C"}, "name": "C" }, "right": { "type": "ClassExpression", - "start":12,"end":38,"loc":{"start":{"line":3,"column":4},"end":{"line":3,"column":30}}, + "start":100,"end":126,"loc":{"start":{"line":3,"column":4},"end":{"line":3,"column":30}}, "id": null, "superClass": null, "body": { "type": "ClassBody", - "start":18,"end":38,"loc":{"start":{"line":3,"column":10},"end":{"line":3,"column":30}}, + "start":106,"end":126,"loc":{"start":{"line":3,"column":10},"end":{"line":3,"column":30}}, "body": [ { "type": "StaticBlock", - "start":20,"end":36,"loc":{"start":{"line":3,"column":12},"end":{"line":3,"column":28}}, + "start":108,"end":124,"loc":{"start":{"line":3,"column":12},"end":{"line":3,"column":28}}, "body": [ { "type": "ExpressionStatement", - "start":29,"end":34,"loc":{"start":{"line":3,"column":21},"end":{"line":3,"column":26}}, + "start":117,"end":122,"loc":{"start":{"line":3,"column":21},"end":{"line":3,"column":26}}, "expression": { "type": "Identifier", - "start":29,"end":34,"loc":{"start":{"line":3,"column":21},"end":{"line":3,"column":26},"identifierName":"await"}, + "start":117,"end":122,"loc":{"start":{"line":3,"column":21},"end":{"line":3,"column":26},"identifierName":"await"}, "name": "await" } } @@ -82,44 +97,40 @@ }, { "type": "ExpressionStatement", - "start":41,"end":78,"loc":{"start":{"line":5,"column":0},"end":{"line":5,"column":37}}, + "start":129,"end":162,"loc":{"start":{"line":5,"column":0},"end":{"line":5,"column":33}}, "expression": { "type": "AssignmentExpression", - "start":41,"end":77,"loc":{"start":{"line":5,"column":0},"end":{"line":5,"column":36}}, + "start":129,"end":161,"loc":{"start":{"line":5,"column":0},"end":{"line":5,"column":32}}, "operator": "=", "left": { "type": "Identifier", - "start":41,"end":42,"loc":{"start":{"line":5,"column":0},"end":{"line":5,"column":1},"identifierName":"C"}, + "start":129,"end":130,"loc":{"start":{"line":5,"column":0},"end":{"line":5,"column":1},"identifierName":"C"}, "name": "C" }, "right": { "type": "ClassExpression", - "start":45,"end":77,"loc":{"start":{"line":5,"column":4},"end":{"line":5,"column":36}}, + "start":133,"end":161,"loc":{"start":{"line":5,"column":4},"end":{"line":5,"column":32}}, "id": null, "superClass": null, "body": { "type": "ClassBody", - "start":51,"end":77,"loc":{"start":{"line":5,"column":10},"end":{"line":5,"column":36}}, + "start":139,"end":161,"loc":{"start":{"line":5,"column":10},"end":{"line":5,"column":32}}, "body": [ { "type": "StaticBlock", - "start":53,"end":75,"loc":{"start":{"line":5,"column":12},"end":{"line":5,"column":34}}, + "start":141,"end":159,"loc":{"start":{"line":5,"column":12},"end":{"line":5,"column":30}}, "body": [ { "type": "ExpressionStatement", - "start":62,"end":73,"loc":{"start":{"line":5,"column":21},"end":{"line":5,"column":32}}, + "start":150,"end":157,"loc":{"start":{"line":5,"column":21},"end":{"line":5,"column":28}}, "expression": { - "type": "ArrowFunctionExpression", - "start":62,"end":73,"loc":{"start":{"line":5,"column":21},"end":{"line":5,"column":32}}, - "id": null, - "generator": false, - "async": false, - "params": [], - "body": { - "type": "Identifier", - "start":68,"end":73,"loc":{"start":{"line":5,"column":27},"end":{"line":5,"column":32},"identifierName":"await"}, - "name": "await" - } + "type": "Identifier", + "start":151,"end":156,"loc":{"start":{"line":5,"column":22},"end":{"line":5,"column":27},"identifierName":"await"}, + "extra": { + "parenthesized": true, + "parenStart": 150 + }, + "name": "await" } } ] @@ -131,51 +142,47 @@ }, { "type": "ExpressionStatement", - "start":80,"end":119,"loc":{"start":{"line":7,"column":0},"end":{"line":7,"column":39}}, + "start":164,"end":203,"loc":{"start":{"line":7,"column":0},"end":{"line":7,"column":39}}, "expression": { "type": "AssignmentExpression", - "start":80,"end":118,"loc":{"start":{"line":7,"column":0},"end":{"line":7,"column":38}}, + "start":164,"end":202,"loc":{"start":{"line":7,"column":0},"end":{"line":7,"column":38}}, "operator": "=", "left": { "type": "Identifier", - "start":80,"end":81,"loc":{"start":{"line":7,"column":0},"end":{"line":7,"column":1},"identifierName":"C"}, + "start":164,"end":165,"loc":{"start":{"line":7,"column":0},"end":{"line":7,"column":1},"identifierName":"C"}, "name": "C" }, "right": { "type": "ClassExpression", - "start":84,"end":118,"loc":{"start":{"line":7,"column":4},"end":{"line":7,"column":38}}, + "start":168,"end":202,"loc":{"start":{"line":7,"column":4},"end":{"line":7,"column":38}}, "id": null, "superClass": null, "body": { "type": "ClassBody", - "start":90,"end":118,"loc":{"start":{"line":7,"column":10},"end":{"line":7,"column":38}}, + "start":174,"end":202,"loc":{"start":{"line":7,"column":10},"end":{"line":7,"column":38}}, "body": [ { "type": "StaticBlock", - "start":92,"end":116,"loc":{"start":{"line":7,"column":12},"end":{"line":7,"column":36}}, + "start":176,"end":200,"loc":{"start":{"line":7,"column":12},"end":{"line":7,"column":36}}, "body": [ { "type": "ExpressionStatement", - "start":101,"end":114,"loc":{"start":{"line":7,"column":21},"end":{"line":7,"column":34}}, + "start":185,"end":198,"loc":{"start":{"line":7,"column":21},"end":{"line":7,"column":34}}, "expression": { - "type": "ArrowFunctionExpression", - "start":101,"end":114,"loc":{"start":{"line":7,"column":21},"end":{"line":7,"column":34}}, - "id": null, - "generator": false, - "async": false, - "params": [ + "type": "CallExpression", + "start":185,"end":198,"loc":{"start":{"line":7,"column":21},"end":{"line":7,"column":34}}, + "callee": { + "type": "Identifier", + "start":185,"end":190,"loc":{"start":{"line":7,"column":21},"end":{"line":7,"column":26},"identifierName":"async"}, + "name": "async" + }, + "arguments": [ { "type": "Identifier", - "start":102,"end":107,"loc":{"start":{"line":7,"column":22},"end":{"line":7,"column":27},"identifierName":"await"}, + "start":192,"end":197,"loc":{"start":{"line":7,"column":28},"end":{"line":7,"column":33},"identifierName":"await"}, "name": "await" } - ], - "body": { - "type": "BlockStatement", - "start":112,"end":114,"loc":{"start":{"line":7,"column":32},"end":{"line":7,"column":34}}, - "body": [], - "directives": [] - } + ] } } ] @@ -187,40 +194,65 @@ }, { "type": "ExpressionStatement", - "start":121,"end":154,"loc":{"start":{"line":9,"column":0},"end":{"line":9,"column":33}}, + "start":205,"end":252,"loc":{"start":{"line":9,"column":0},"end":{"line":9,"column":47}}, "expression": { "type": "AssignmentExpression", - "start":121,"end":153,"loc":{"start":{"line":9,"column":0},"end":{"line":9,"column":32}}, + "start":205,"end":251,"loc":{"start":{"line":9,"column":0},"end":{"line":9,"column":46}}, "operator": "=", "left": { "type": "Identifier", - "start":121,"end":122,"loc":{"start":{"line":9,"column":0},"end":{"line":9,"column":1},"identifierName":"C"}, + "start":205,"end":206,"loc":{"start":{"line":9,"column":0},"end":{"line":9,"column":1},"identifierName":"C"}, "name": "C" }, "right": { "type": "ClassExpression", - "start":125,"end":153,"loc":{"start":{"line":9,"column":4},"end":{"line":9,"column":32}}, + "start":209,"end":251,"loc":{"start":{"line":9,"column":4},"end":{"line":9,"column":46}}, "id": null, "superClass": null, "body": { "type": "ClassBody", - "start":131,"end":153,"loc":{"start":{"line":9,"column":10},"end":{"line":9,"column":32}}, + "start":215,"end":251,"loc":{"start":{"line":9,"column":10},"end":{"line":9,"column":46}}, "body": [ { "type": "StaticBlock", - "start":133,"end":151,"loc":{"start":{"line":9,"column":12},"end":{"line":9,"column":30}}, + "start":217,"end":249,"loc":{"start":{"line":9,"column":12},"end":{"line":9,"column":44}}, "body": [ { "type": "ExpressionStatement", - "start":142,"end":149,"loc":{"start":{"line":9,"column":21},"end":{"line":9,"column":28}}, + "start":226,"end":247,"loc":{"start":{"line":9,"column":21},"end":{"line":9,"column":42}}, "expression": { - "type": "Identifier", - "start":143,"end":148,"loc":{"start":{"line":9,"column":22},"end":{"line":9,"column":27},"identifierName":"await"}, - "extra": { - "parenthesized": true, - "parenStart": 142 + "type": "CallExpression", + "start":226,"end":247,"loc":{"start":{"line":9,"column":21},"end":{"line":9,"column":42}}, + "callee": { + "type": "Identifier", + "start":226,"end":231,"loc":{"start":{"line":9,"column":21},"end":{"line":9,"column":26},"identifierName":"async"}, + "name": "async" }, - "name": "await" + "arguments": [ + { + "type": "ObjectExpression", + "start":233,"end":246,"loc":{"start":{"line":9,"column":28},"end":{"line":9,"column":41}}, + "properties": [ + { + "type": "ObjectProperty", + "start":235,"end":245,"loc":{"start":{"line":9,"column":30},"end":{"line":9,"column":40}}, + "method": false, + "computed": true, + "key": { + "type": "Identifier", + "start":236,"end":241,"loc":{"start":{"line":9,"column":31},"end":{"line":9,"column":36},"identifierName":"await"}, + "name": "await" + }, + "shorthand": false, + "value": { + "type": "Identifier", + "start":244,"end":245,"loc":{"start":{"line":9,"column":39},"end":{"line":9,"column":40},"identifierName":"x"}, + "name": "x" + } + } + ] + } + ] } } ] @@ -232,51 +264,118 @@ }, { "type": "ExpressionStatement", - "start":156,"end":201,"loc":{"start":{"line":11,"column":0},"end":{"line":11,"column":45}}, + "start":254,"end":299,"loc":{"start":{"line":11,"column":0},"end":{"line":11,"column":45}}, + "trailingComments": [ + { + "type": "CommentLine", + "value": " await as label is not allowed", + "start":300,"end":332,"loc":{"start":{"line":12,"column":0},"end":{"line":12,"column":32}} + } + ], + "expression": { + "type": "ArrowFunctionExpression", + "start":254,"end":298,"loc":{"start":{"line":11,"column":0},"end":{"line":11,"column":44}}, + "id": null, + "generator": false, + "async": true, + "params": [ + { + "type": "AssignmentPattern", + "start":261,"end":291,"loc":{"start":{"line":11,"column":7},"end":{"line":11,"column":37}}, + "left": { + "type": "Identifier", + "start":261,"end":262,"loc":{"start":{"line":11,"column":7},"end":{"line":11,"column":8},"identifierName":"x"}, + "name": "x" + }, + "right": { + "type": "ClassExpression", + "start":265,"end":291,"loc":{"start":{"line":11,"column":11},"end":{"line":11,"column":37}}, + "id": null, + "superClass": null, + "body": { + "type": "ClassBody", + "start":271,"end":291,"loc":{"start":{"line":11,"column":17},"end":{"line":11,"column":37}}, + "body": [ + { + "type": "StaticBlock", + "start":273,"end":289,"loc":{"start":{"line":11,"column":19},"end":{"line":11,"column":35}}, + "body": [ + { + "type": "ExpressionStatement", + "start":282,"end":287,"loc":{"start":{"line":11,"column":28},"end":{"line":11,"column":33}}, + "expression": { + "type": "Identifier", + "start":282,"end":287,"loc":{"start":{"line":11,"column":28},"end":{"line":11,"column":33},"identifierName":"await"}, + "name": "await" + } + } + ] + } + ] + } + } + } + ], + "body": { + "type": "BlockStatement", + "start":296,"end":298,"loc":{"start":{"line":11,"column":42},"end":{"line":11,"column":44}}, + "body": [], + "directives": [] + } + } + }, + { + "type": "ExpressionStatement", + "start":333,"end":367,"loc":{"start":{"line":13,"column":0},"end":{"line":13,"column":34}}, + "leadingComments": [ + { + "type": "CommentLine", + "value": " await as label is not allowed", + "start":300,"end":332,"loc":{"start":{"line":12,"column":0},"end":{"line":12,"column":32}} + } + ], "expression": { "type": "AssignmentExpression", - "start":156,"end":200,"loc":{"start":{"line":11,"column":0},"end":{"line":11,"column":44}}, + "start":333,"end":366,"loc":{"start":{"line":13,"column":0},"end":{"line":13,"column":33}}, "operator": "=", "left": { "type": "Identifier", - "start":156,"end":157,"loc":{"start":{"line":11,"column":0},"end":{"line":11,"column":1},"identifierName":"C"}, + "start":333,"end":334,"loc":{"start":{"line":13,"column":0},"end":{"line":13,"column":1},"identifierName":"C"}, "name": "C" }, "right": { "type": "ClassExpression", - "start":160,"end":200,"loc":{"start":{"line":11,"column":4},"end":{"line":11,"column":44}}, + "start":337,"end":366,"loc":{"start":{"line":13,"column":4},"end":{"line":13,"column":33}}, "id": null, "superClass": null, "body": { "type": "ClassBody", - "start":166,"end":200,"loc":{"start":{"line":11,"column":10},"end":{"line":11,"column":44}}, + "start":343,"end":366,"loc":{"start":{"line":13,"column":10},"end":{"line":13,"column":33}}, "body": [ { "type": "StaticBlock", - "start":168,"end":198,"loc":{"start":{"line":11,"column":12},"end":{"line":11,"column":42}}, + "start":345,"end":364,"loc":{"start":{"line":13,"column":12},"end":{"line":13,"column":31}}, "body": [ { - "type": "ExpressionStatement", - "start":177,"end":196,"loc":{"start":{"line":11,"column":21},"end":{"line":11,"column":40}}, - "expression": { - "type": "ArrowFunctionExpression", - "start":177,"end":196,"loc":{"start":{"line":11,"column":21},"end":{"line":11,"column":40}}, - "id": null, - "generator": false, - "async": true, - "params": [ - { - "type": "Identifier", - "start":184,"end":189,"loc":{"start":{"line":11,"column":28},"end":{"line":11,"column":33},"identifierName":"await"}, - "name": "await" - } - ], - "body": { - "type": "BlockStatement", - "start":194,"end":196,"loc":{"start":{"line":11,"column":38},"end":{"line":11,"column":40}}, - "body": [], - "directives": [] + "type": "LabeledStatement", + "start":354,"end":362,"loc":{"start":{"line":13,"column":21},"end":{"line":13,"column":29}}, + "body": { + "type": "ExpressionStatement", + "start":361,"end":362,"loc":{"start":{"line":13,"column":28},"end":{"line":13,"column":29}}, + "expression": { + "type": "NumericLiteral", + "start":361,"end":362,"loc":{"start":{"line":13,"column":28},"end":{"line":13,"column":29}}, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 } + }, + "label": { + "type": "Identifier", + "start":354,"end":359,"loc":{"start":{"line":13,"column":21},"end":{"line":13,"column":26},"identifierName":"await"}, + "name": "await" } } ] @@ -288,45 +387,60 @@ }, { "type": "ExpressionStatement", - "start":203,"end":242,"loc":{"start":{"line":13,"column":0},"end":{"line":13,"column":39}}, + "start":369,"end":414,"loc":{"start":{"line":15,"column":0},"end":{"line":15,"column":45}}, + "trailingComments": [ + { + "type": "CommentLine", + "value": " await binding in function declaration is not allowed", + "start":415,"end":470,"loc":{"start":{"line":16,"column":0},"end":{"line":16,"column":55}} + } + ], "expression": { "type": "AssignmentExpression", - "start":203,"end":241,"loc":{"start":{"line":13,"column":0},"end":{"line":13,"column":38}}, + "start":369,"end":413,"loc":{"start":{"line":15,"column":0},"end":{"line":15,"column":44}}, "operator": "=", "left": { "type": "Identifier", - "start":203,"end":204,"loc":{"start":{"line":13,"column":0},"end":{"line":13,"column":1},"identifierName":"C"}, + "start":369,"end":370,"loc":{"start":{"line":15,"column":0},"end":{"line":15,"column":1},"identifierName":"C"}, "name": "C" }, "right": { "type": "ClassExpression", - "start":207,"end":241,"loc":{"start":{"line":13,"column":4},"end":{"line":13,"column":38}}, + "start":373,"end":413,"loc":{"start":{"line":15,"column":4},"end":{"line":15,"column":44}}, "id": null, "superClass": null, "body": { "type": "ClassBody", - "start":213,"end":241,"loc":{"start":{"line":13,"column":10},"end":{"line":13,"column":38}}, + "start":379,"end":413,"loc":{"start":{"line":15,"column":10},"end":{"line":15,"column":44}}, "body": [ { "type": "StaticBlock", - "start":215,"end":239,"loc":{"start":{"line":13,"column":12},"end":{"line":13,"column":36}}, + "start":381,"end":411,"loc":{"start":{"line":15,"column":12},"end":{"line":15,"column":42}}, "body": [ { - "type": "ExpressionStatement", - "start":224,"end":237,"loc":{"start":{"line":13,"column":21},"end":{"line":13,"column":34}}, - "expression": { - "type": "CallExpression", - "start":224,"end":237,"loc":{"start":{"line":13,"column":21},"end":{"line":13,"column":34}}, - "callee": { - "type": "Identifier", - "start":224,"end":229,"loc":{"start":{"line":13,"column":21},"end":{"line":13,"column":26},"identifierName":"async"}, - "name": "async" - }, - "arguments": [ + "type": "ClassDeclaration", + "start":390,"end":409,"loc":{"start":{"line":15,"column":21},"end":{"line":15,"column":40}}, + "id": { + "type": "Identifier", + "start":396,"end":397,"loc":{"start":{"line":15,"column":27},"end":{"line":15,"column":28},"identifierName":"D"}, + "name": "D" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start":398,"end":409,"loc":{"start":{"line":15,"column":29},"end":{"line":15,"column":40}}, + "body": [ { - "type": "Identifier", - "start":231,"end":236,"loc":{"start":{"line":13,"column":28},"end":{"line":13,"column":33},"identifierName":"await"}, - "name": "await" + "type": "ClassProperty", + "start":400,"end":407,"loc":{"start":{"line":15,"column":31},"end":{"line":15,"column":38}}, + "static": false, + "computed": true, + "key": { + "type": "Identifier", + "start":401,"end":406,"loc":{"start":{"line":15,"column":32},"end":{"line":15,"column":37},"identifierName":"await"}, + "name": "await" + }, + "value": null } ] } @@ -340,69 +454,59 @@ }, { "type": "ExpressionStatement", - "start":244,"end":291,"loc":{"start":{"line":15,"column":0},"end":{"line":15,"column":47}}, + "start":471,"end":516,"loc":{"start":{"line":17,"column":0},"end":{"line":17,"column":45}}, + "leadingComments": [ + { + "type": "CommentLine", + "value": " await binding in function declaration is not allowed", + "start":415,"end":470,"loc":{"start":{"line":16,"column":0},"end":{"line":16,"column":55}} + } + ], + "trailingComments": [ + { + "type": "CommentLine", + "value": " await binding in class declaration is not allowed", + "start":517,"end":569,"loc":{"start":{"line":18,"column":0},"end":{"line":18,"column":52}} + } + ], "expression": { "type": "AssignmentExpression", - "start":244,"end":290,"loc":{"start":{"line":15,"column":0},"end":{"line":15,"column":46}}, + "start":471,"end":515,"loc":{"start":{"line":17,"column":0},"end":{"line":17,"column":44}}, "operator": "=", "left": { "type": "Identifier", - "start":244,"end":245,"loc":{"start":{"line":15,"column":0},"end":{"line":15,"column":1},"identifierName":"C"}, + "start":471,"end":472,"loc":{"start":{"line":17,"column":0},"end":{"line":17,"column":1},"identifierName":"C"}, "name": "C" }, "right": { "type": "ClassExpression", - "start":248,"end":290,"loc":{"start":{"line":15,"column":4},"end":{"line":15,"column":46}}, + "start":475,"end":515,"loc":{"start":{"line":17,"column":4},"end":{"line":17,"column":44}}, "id": null, "superClass": null, "body": { "type": "ClassBody", - "start":254,"end":290,"loc":{"start":{"line":15,"column":10},"end":{"line":15,"column":46}}, + "start":481,"end":515,"loc":{"start":{"line":17,"column":10},"end":{"line":17,"column":44}}, "body": [ { "type": "StaticBlock", - "start":256,"end":288,"loc":{"start":{"line":15,"column":12},"end":{"line":15,"column":44}}, + "start":483,"end":513,"loc":{"start":{"line":17,"column":12},"end":{"line":17,"column":42}}, "body": [ { - "type": "ExpressionStatement", - "start":265,"end":286,"loc":{"start":{"line":15,"column":21},"end":{"line":15,"column":42}}, - "expression": { - "type": "ArrowFunctionExpression", - "start":265,"end":286,"loc":{"start":{"line":15,"column":21},"end":{"line":15,"column":42}}, - "id": null, - "generator": false, - "async": false, - "params": [ - { - "type": "ObjectPattern", - "start":266,"end":279,"loc":{"start":{"line":15,"column":22},"end":{"line":15,"column":35}}, - "properties": [ - { - "type": "ObjectProperty", - "start":268,"end":278,"loc":{"start":{"line":15,"column":24},"end":{"line":15,"column":34}}, - "method": false, - "computed": true, - "key": { - "type": "Identifier", - "start":269,"end":274,"loc":{"start":{"line":15,"column":25},"end":{"line":15,"column":30},"identifierName":"await"}, - "name": "await" - }, - "shorthand": false, - "value": { - "type": "Identifier", - "start":277,"end":278,"loc":{"start":{"line":15,"column":33},"end":{"line":15,"column":34},"identifierName":"x"}, - "name": "x" - } - } - ] - } - ], - "body": { - "type": "BlockStatement", - "start":284,"end":286,"loc":{"start":{"line":15,"column":40},"end":{"line":15,"column":42}}, - "body": [], - "directives": [] - } + "type": "FunctionDeclaration", + "start":492,"end":511,"loc":{"start":{"line":17,"column":21},"end":{"line":17,"column":40}}, + "id": { + "type": "Identifier", + "start":501,"end":506,"loc":{"start":{"line":17,"column":30},"end":{"line":17,"column":35},"identifierName":"await"}, + "name": "await" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start":509,"end":511,"loc":{"start":{"line":17,"column":38},"end":{"line":17,"column":40}}, + "body": [], + "directives": [] } } ] @@ -414,58 +518,125 @@ }, { "type": "ExpressionStatement", - "start":293,"end":334,"loc":{"start":{"line":17,"column":0},"end":{"line":17,"column":41}}, + "start":570,"end":610,"loc":{"start":{"line":19,"column":0},"end":{"line":19,"column":40}}, + "leadingComments": [ + { + "type": "CommentLine", + "value": " await binding in class declaration is not allowed", + "start":517,"end":569,"loc":{"start":{"line":18,"column":0},"end":{"line":18,"column":52}} + } + ], + "trailingComments": [ + { + "type": "CommentLine", + "value": " await binding in class expression is not allowed", + "start":611,"end":662,"loc":{"start":{"line":20,"column":0},"end":{"line":20,"column":51}} + } + ], "expression": { "type": "AssignmentExpression", - "start":293,"end":333,"loc":{"start":{"line":17,"column":0},"end":{"line":17,"column":40}}, + "start":570,"end":609,"loc":{"start":{"line":19,"column":0},"end":{"line":19,"column":39}}, "operator": "=", "left": { "type": "Identifier", - "start":293,"end":294,"loc":{"start":{"line":17,"column":0},"end":{"line":17,"column":1},"identifierName":"C"}, + "start":570,"end":571,"loc":{"start":{"line":19,"column":0},"end":{"line":19,"column":1},"identifierName":"C"}, "name": "C" }, "right": { "type": "ClassExpression", - "start":297,"end":333,"loc":{"start":{"line":17,"column":4},"end":{"line":17,"column":40}}, + "start":574,"end":609,"loc":{"start":{"line":19,"column":4},"end":{"line":19,"column":39}}, "id": null, "superClass": null, "body": { "type": "ClassBody", - "start":303,"end":333,"loc":{"start":{"line":17,"column":10},"end":{"line":17,"column":40}}, + "start":580,"end":609,"loc":{"start":{"line":19,"column":10},"end":{"line":19,"column":39}}, "body": [ { "type": "StaticBlock", - "start":305,"end":331,"loc":{"start":{"line":17,"column":12},"end":{"line":17,"column":38}}, + "start":582,"end":607,"loc":{"start":{"line":19,"column":12},"end":{"line":19,"column":37}}, + "body": [ + { + "type": "ClassDeclaration", + "start":591,"end":605,"loc":{"start":{"line":19,"column":21},"end":{"line":19,"column":35}}, + "id": { + "type": "Identifier", + "start":597,"end":602,"loc":{"start":{"line":19,"column":27},"end":{"line":19,"column":32},"identifierName":"await"}, + "name": "await" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start":603,"end":605,"loc":{"start":{"line":19,"column":33},"end":{"line":19,"column":35}}, + "body": [] + } + } + ] + } + ] + } + } + } + }, + { + "type": "ExpressionStatement", + "start":663,"end":705,"loc":{"start":{"line":21,"column":0},"end":{"line":21,"column":42}}, + "leadingComments": [ + { + "type": "CommentLine", + "value": " await binding in class expression is not allowed", + "start":611,"end":662,"loc":{"start":{"line":20,"column":0},"end":{"line":20,"column":51}} + } + ], + "trailingComments": [ + { + "type": "CommentLine", + "value": " await in arrow parameters is not allowed", + "start":706,"end":749,"loc":{"start":{"line":22,"column":0},"end":{"line":22,"column":43}} + } + ], + "expression": { + "type": "AssignmentExpression", + "start":663,"end":704,"loc":{"start":{"line":21,"column":0},"end":{"line":21,"column":41}}, + "operator": "=", + "left": { + "type": "Identifier", + "start":663,"end":664,"loc":{"start":{"line":21,"column":0},"end":{"line":21,"column":1},"identifierName":"C"}, + "name": "C" + }, + "right": { + "type": "ClassExpression", + "start":667,"end":704,"loc":{"start":{"line":21,"column":4},"end":{"line":21,"column":41}}, + "id": null, + "superClass": null, + "body": { + "type": "ClassBody", + "start":673,"end":704,"loc":{"start":{"line":21,"column":10},"end":{"line":21,"column":41}}, + "body": [ + { + "type": "StaticBlock", + "start":675,"end":702,"loc":{"start":{"line":21,"column":12},"end":{"line":21,"column":39}}, "body": [ { "type": "ExpressionStatement", - "start":314,"end":329,"loc":{"start":{"line":17,"column":21},"end":{"line":17,"column":36}}, + "start":684,"end":700,"loc":{"start":{"line":21,"column":21},"end":{"line":21,"column":37}}, "expression": { - "type": "ObjectExpression", - "start":315,"end":328,"loc":{"start":{"line":17,"column":22},"end":{"line":17,"column":35}}, + "type": "ClassExpression", + "start":685,"end":699,"loc":{"start":{"line":21,"column":22},"end":{"line":21,"column":36}}, "extra": { "parenthesized": true, - "parenStart": 314 + "parenStart": 684 }, - "properties": [ - { - "type": "ObjectProperty", - "start":317,"end":327,"loc":{"start":{"line":17,"column":24},"end":{"line":17,"column":34}}, - "method": false, - "computed": true, - "key": { - "type": "Identifier", - "start":318,"end":323,"loc":{"start":{"line":17,"column":25},"end":{"line":17,"column":30},"identifierName":"await"}, - "name": "await" - }, - "shorthand": false, - "value": { - "type": "Identifier", - "start":326,"end":327,"loc":{"start":{"line":17,"column":33},"end":{"line":17,"column":34},"identifierName":"x"}, - "name": "x" - } - } - ] + "id": { + "type": "Identifier", + "start":691,"end":696,"loc":{"start":{"line":21,"column":28},"end":{"line":21,"column":33},"identifierName":"await"}, + "name": "await" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start":697,"end":699,"loc":{"start":{"line":21,"column":34},"end":{"line":21,"column":36}}, + "body": [] + } } } ] @@ -477,66 +648,55 @@ }, { "type": "ExpressionStatement", - "start":336,"end":389,"loc":{"start":{"line":19,"column":0},"end":{"line":19,"column":53}}, + "start":750,"end":789,"loc":{"start":{"line":23,"column":0},"end":{"line":23,"column":39}}, + "leadingComments": [ + { + "type": "CommentLine", + "value": " await in arrow parameters is not allowed", + "start":706,"end":749,"loc":{"start":{"line":22,"column":0},"end":{"line":22,"column":43}} + } + ], "expression": { "type": "AssignmentExpression", - "start":336,"end":388,"loc":{"start":{"line":19,"column":0},"end":{"line":19,"column":52}}, + "start":750,"end":788,"loc":{"start":{"line":23,"column":0},"end":{"line":23,"column":38}}, "operator": "=", "left": { "type": "Identifier", - "start":336,"end":337,"loc":{"start":{"line":19,"column":0},"end":{"line":19,"column":1},"identifierName":"C"}, + "start":750,"end":751,"loc":{"start":{"line":23,"column":0},"end":{"line":23,"column":1},"identifierName":"C"}, "name": "C" }, "right": { "type": "ClassExpression", - "start":340,"end":388,"loc":{"start":{"line":19,"column":4},"end":{"line":19,"column":52}}, + "start":754,"end":788,"loc":{"start":{"line":23,"column":4},"end":{"line":23,"column":38}}, "id": null, "superClass": null, "body": { "type": "ClassBody", - "start":346,"end":388,"loc":{"start":{"line":19,"column":10},"end":{"line":19,"column":52}}, + "start":760,"end":788,"loc":{"start":{"line":23,"column":10},"end":{"line":23,"column":38}}, "body": [ { "type": "StaticBlock", - "start":348,"end":386,"loc":{"start":{"line":19,"column":12},"end":{"line":19,"column":50}}, + "start":762,"end":786,"loc":{"start":{"line":23,"column":12},"end":{"line":23,"column":36}}, "body": [ { "type": "ExpressionStatement", - "start":357,"end":384,"loc":{"start":{"line":19,"column":21},"end":{"line":19,"column":48}}, + "start":771,"end":784,"loc":{"start":{"line":23,"column":21},"end":{"line":23,"column":34}}, "expression": { "type": "ArrowFunctionExpression", - "start":357,"end":384,"loc":{"start":{"line":19,"column":21},"end":{"line":19,"column":48}}, + "start":771,"end":784,"loc":{"start":{"line":23,"column":21},"end":{"line":23,"column":34}}, "id": null, "generator": false, - "async": true, + "async": false, "params": [ { - "type": "ObjectPattern", - "start":364,"end":377,"loc":{"start":{"line":19,"column":28},"end":{"line":19,"column":41}}, - "properties": [ - { - "type": "ObjectProperty", - "start":366,"end":376,"loc":{"start":{"line":19,"column":30},"end":{"line":19,"column":40}}, - "method": false, - "computed": true, - "key": { - "type": "Identifier", - "start":367,"end":372,"loc":{"start":{"line":19,"column":31},"end":{"line":19,"column":36},"identifierName":"await"}, - "name": "await" - }, - "shorthand": false, - "value": { - "type": "Identifier", - "start":375,"end":376,"loc":{"start":{"line":19,"column":39},"end":{"line":19,"column":40},"identifierName":"x"}, - "name": "x" - } - } - ] + "type": "Identifier", + "start":772,"end":777,"loc":{"start":{"line":23,"column":22},"end":{"line":23,"column":27},"identifierName":"await"}, + "name": "await" } ], "body": { "type": "BlockStatement", - "start":382,"end":384,"loc":{"start":{"line":19,"column":46},"end":{"line":19,"column":48}}, + "start":782,"end":784,"loc":{"start":{"line":23,"column":32},"end":{"line":23,"column":34}}, "body": [], "directives": [] } @@ -551,65 +711,60 @@ }, { "type": "ExpressionStatement", - "start":391,"end":438,"loc":{"start":{"line":21,"column":0},"end":{"line":21,"column":47}}, + "start":791,"end":834,"loc":{"start":{"line":25,"column":0},"end":{"line":25,"column":43}}, "expression": { "type": "AssignmentExpression", - "start":391,"end":437,"loc":{"start":{"line":21,"column":0},"end":{"line":21,"column":46}}, + "start":791,"end":833,"loc":{"start":{"line":25,"column":0},"end":{"line":25,"column":42}}, "operator": "=", "left": { "type": "Identifier", - "start":391,"end":392,"loc":{"start":{"line":21,"column":0},"end":{"line":21,"column":1},"identifierName":"C"}, + "start":791,"end":792,"loc":{"start":{"line":25,"column":0},"end":{"line":25,"column":1},"identifierName":"C"}, "name": "C" }, "right": { "type": "ClassExpression", - "start":395,"end":437,"loc":{"start":{"line":21,"column":4},"end":{"line":21,"column":46}}, + "start":795,"end":833,"loc":{"start":{"line":25,"column":4},"end":{"line":25,"column":42}}, "id": null, "superClass": null, "body": { "type": "ClassBody", - "start":401,"end":437,"loc":{"start":{"line":21,"column":10},"end":{"line":21,"column":46}}, + "start":801,"end":833,"loc":{"start":{"line":25,"column":10},"end":{"line":25,"column":42}}, "body": [ { "type": "StaticBlock", - "start":403,"end":435,"loc":{"start":{"line":21,"column":12},"end":{"line":21,"column":44}}, + "start":803,"end":831,"loc":{"start":{"line":25,"column":12},"end":{"line":25,"column":40}}, "body": [ { "type": "ExpressionStatement", - "start":412,"end":433,"loc":{"start":{"line":21,"column":21},"end":{"line":21,"column":42}}, + "start":812,"end":829,"loc":{"start":{"line":25,"column":21},"end":{"line":25,"column":38}}, "expression": { - "type": "CallExpression", - "start":412,"end":433,"loc":{"start":{"line":21,"column":21},"end":{"line":21,"column":42}}, - "callee": { - "type": "Identifier", - "start":412,"end":417,"loc":{"start":{"line":21,"column":21},"end":{"line":21,"column":26},"identifierName":"async"}, - "name": "async" - }, - "arguments": [ + "type": "ArrowFunctionExpression", + "start":812,"end":829,"loc":{"start":{"line":25,"column":21},"end":{"line":25,"column":38}}, + "id": null, + "generator": false, + "async": false, + "params": [ { - "type": "ObjectExpression", - "start":419,"end":432,"loc":{"start":{"line":21,"column":28},"end":{"line":21,"column":41}}, - "properties": [ - { - "type": "ObjectProperty", - "start":421,"end":431,"loc":{"start":{"line":21,"column":30},"end":{"line":21,"column":40}}, - "method": false, - "computed": true, - "key": { - "type": "Identifier", - "start":422,"end":427,"loc":{"start":{"line":21,"column":31},"end":{"line":21,"column":36},"identifierName":"await"}, - "name": "await" - }, - "shorthand": false, - "value": { - "type": "Identifier", - "start":430,"end":431,"loc":{"start":{"line":21,"column":39},"end":{"line":21,"column":40},"identifierName":"x"}, - "name": "x" - } - } - ] + "type": "AssignmentPattern", + "start":813,"end":822,"loc":{"start":{"line":25,"column":22},"end":{"line":25,"column":31}}, + "left": { + "type": "Identifier", + "start":813,"end":814,"loc":{"start":{"line":25,"column":22},"end":{"line":25,"column":23},"identifierName":"x"}, + "name": "x" + }, + "right": { + "type": "Identifier", + "start":817,"end":822,"loc":{"start":{"line":25,"column":26},"end":{"line":25,"column":31},"identifierName":"await"}, + "name": "await" + } } - ] + ], + "body": { + "type": "BlockStatement", + "start":827,"end":829,"loc":{"start":{"line":25,"column":36},"end":{"line":25,"column":38}}, + "body": [], + "directives": [] + } } } ] @@ -621,100 +776,69 @@ }, { "type": "ExpressionStatement", - "start":440,"end":485,"loc":{"start":{"line":23,"column":0},"end":{"line":23,"column":45}}, - "expression": { - "type": "ArrowFunctionExpression", - "start":440,"end":484,"loc":{"start":{"line":23,"column":0},"end":{"line":23,"column":44}}, - "id": null, - "generator": false, - "async": true, - "params": [ - { - "type": "AssignmentPattern", - "start":447,"end":477,"loc":{"start":{"line":23,"column":7},"end":{"line":23,"column":37}}, - "left": { - "type": "Identifier", - "start":447,"end":448,"loc":{"start":{"line":23,"column":7},"end":{"line":23,"column":8},"identifierName":"x"}, - "name": "x" - }, - "right": { - "type": "ClassExpression", - "start":451,"end":477,"loc":{"start":{"line":23,"column":11},"end":{"line":23,"column":37}}, - "id": null, - "superClass": null, - "body": { - "type": "ClassBody", - "start":457,"end":477,"loc":{"start":{"line":23,"column":17},"end":{"line":23,"column":37}}, - "body": [ - { - "type": "StaticBlock", - "start":459,"end":475,"loc":{"start":{"line":23,"column":19},"end":{"line":23,"column":35}}, - "body": [ - { - "type": "ExpressionStatement", - "start":468,"end":473,"loc":{"start":{"line":23,"column":28},"end":{"line":23,"column":33}}, - "expression": { - "type": "Identifier", - "start":468,"end":473,"loc":{"start":{"line":23,"column":28},"end":{"line":23,"column":33},"identifierName":"await"}, - "name": "await" - } - } - ] - } - ] - } - } - } - ], - "body": { - "type": "BlockStatement", - "start":482,"end":484,"loc":{"start":{"line":23,"column":42},"end":{"line":23,"column":44}}, - "body": [], - "directives": [] - } - } - }, - { - "type": "ExpressionStatement", - "start":487,"end":532,"loc":{"start":{"line":25,"column":0},"end":{"line":25,"column":45}}, + "start":836,"end":884,"loc":{"start":{"line":27,"column":0},"end":{"line":27,"column":48}}, "expression": { "type": "AssignmentExpression", - "start":487,"end":531,"loc":{"start":{"line":25,"column":0},"end":{"line":25,"column":44}}, + "start":836,"end":883,"loc":{"start":{"line":27,"column":0},"end":{"line":27,"column":47}}, "operator": "=", "left": { "type": "Identifier", - "start":487,"end":488,"loc":{"start":{"line":25,"column":0},"end":{"line":25,"column":1},"identifierName":"C"}, + "start":836,"end":837,"loc":{"start":{"line":27,"column":0},"end":{"line":27,"column":1},"identifierName":"C"}, "name": "C" }, "right": { "type": "ClassExpression", - "start":491,"end":531,"loc":{"start":{"line":25,"column":4},"end":{"line":25,"column":44}}, + "start":840,"end":883,"loc":{"start":{"line":27,"column":4},"end":{"line":27,"column":47}}, "id": null, "superClass": null, "body": { "type": "ClassBody", - "start":497,"end":531,"loc":{"start":{"line":25,"column":10},"end":{"line":25,"column":44}}, + "start":846,"end":883,"loc":{"start":{"line":27,"column":10},"end":{"line":27,"column":47}}, "body": [ { "type": "StaticBlock", - "start":499,"end":529,"loc":{"start":{"line":25,"column":12},"end":{"line":25,"column":42}}, + "start":848,"end":881,"loc":{"start":{"line":27,"column":12},"end":{"line":27,"column":45}}, "body": [ { - "type": "FunctionDeclaration", - "start":508,"end":527,"loc":{"start":{"line":25,"column":21},"end":{"line":25,"column":40}}, - "id": { - "type": "Identifier", - "start":517,"end":522,"loc":{"start":{"line":25,"column":30},"end":{"line":25,"column":35},"identifierName":"await"}, - "name": "await" - }, - "generator": false, - "async": false, - "params": [], - "body": { - "type": "BlockStatement", - "start":525,"end":527,"loc":{"start":{"line":25,"column":38},"end":{"line":25,"column":40}}, - "body": [], - "directives": [] + "type": "ExpressionStatement", + "start":857,"end":879,"loc":{"start":{"line":27,"column":21},"end":{"line":27,"column":43}}, + "expression": { + "type": "ArrowFunctionExpression", + "start":857,"end":879,"loc":{"start":{"line":27,"column":21},"end":{"line":27,"column":43}}, + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "ObjectPattern", + "start":858,"end":872,"loc":{"start":{"line":27,"column":22},"end":{"line":27,"column":36}}, + "properties": [ + { + "type": "ObjectProperty", + "start":860,"end":870,"loc":{"start":{"line":27,"column":24},"end":{"line":27,"column":34}}, + "method": false, + "computed": true, + "key": { + "type": "Identifier", + "start":861,"end":866,"loc":{"start":{"line":27,"column":25},"end":{"line":27,"column":30},"identifierName":"await"}, + "name": "await" + }, + "shorthand": false, + "value": { + "type": "Identifier", + "start":869,"end":870,"loc":{"start":{"line":27,"column":33},"end":{"line":27,"column":34},"identifierName":"x"}, + "name": "x" + } + } + ] + } + ], + "body": { + "type": "BlockStatement", + "start":877,"end":879,"loc":{"start":{"line":27,"column":41},"end":{"line":27,"column":43}}, + "body": [], + "directives": [] + } } } ] @@ -726,50 +850,44 @@ }, { "type": "ExpressionStatement", - "start":534,"end":568,"loc":{"start":{"line":27,"column":0},"end":{"line":27,"column":34}}, + "start":886,"end":921,"loc":{"start":{"line":29,"column":0},"end":{"line":29,"column":35}}, "expression": { "type": "AssignmentExpression", - "start":534,"end":567,"loc":{"start":{"line":27,"column":0},"end":{"line":27,"column":33}}, + "start":886,"end":920,"loc":{"start":{"line":29,"column":0},"end":{"line":29,"column":34}}, "operator": "=", "left": { "type": "Identifier", - "start":534,"end":535,"loc":{"start":{"line":27,"column":0},"end":{"line":27,"column":1},"identifierName":"C"}, + "start":886,"end":887,"loc":{"start":{"line":29,"column":0},"end":{"line":29,"column":1},"identifierName":"C"}, "name": "C" }, "right": { "type": "ClassExpression", - "start":538,"end":567,"loc":{"start":{"line":27,"column":4},"end":{"line":27,"column":33}}, + "start":890,"end":920,"loc":{"start":{"line":29,"column":4},"end":{"line":29,"column":34}}, "id": null, "superClass": null, "body": { "type": "ClassBody", - "start":544,"end":567,"loc":{"start":{"line":27,"column":10},"end":{"line":27,"column":33}}, + "start":896,"end":920,"loc":{"start":{"line":29,"column":10},"end":{"line":29,"column":34}}, "body": [ { "type": "StaticBlock", - "start":546,"end":565,"loc":{"start":{"line":27,"column":12},"end":{"line":27,"column":31}}, + "start":898,"end":918,"loc":{"start":{"line":29,"column":12},"end":{"line":29,"column":32}}, "body": [ { - "type": "LabeledStatement", - "start":555,"end":563,"loc":{"start":{"line":27,"column":21},"end":{"line":27,"column":29}}, - "body": { - "type": "ExpressionStatement", - "start":562,"end":563,"loc":{"start":{"line":27,"column":28},"end":{"line":27,"column":29}}, - "expression": { - "type": "NumericLiteral", - "start":562,"end":563,"loc":{"start":{"line":27,"column":28},"end":{"line":27,"column":29}}, - "extra": { - "rawValue": 0, - "raw": "0" - }, - "value": 0 + "type": "BlockStatement", + "start":907,"end":916,"loc":{"start":{"line":29,"column":21},"end":{"line":29,"column":30}}, + "body": [ + { + "type": "ExpressionStatement", + "start":909,"end":914,"loc":{"start":{"line":29,"column":23},"end":{"line":29,"column":28}}, + "expression": { + "type": "Identifier", + "start":909,"end":914,"loc":{"start":{"line":29,"column":23},"end":{"line":29,"column":28},"identifierName":"await"}, + "name": "await" + } } - }, - "label": { - "type": "Identifier", - "start":555,"end":560,"loc":{"start":{"line":27,"column":21},"end":{"line":27,"column":26},"identifierName":"await"}, - "name": "await" - } + ], + "directives": [] } ] } @@ -780,5 +898,37 @@ } ], "directives": [] - } + }, + "comments": [ + { + "type": "CommentLine", + "value": " This file enumerates all the disallowed cases, for allowed cases, see await-binding-*", + "start":7,"end":95,"loc":{"start":{"line":2,"column":0},"end":{"line":2,"column":88}} + }, + { + "type": "CommentLine", + "value": " await as label is not allowed", + "start":300,"end":332,"loc":{"start":{"line":12,"column":0},"end":{"line":12,"column":32}} + }, + { + "type": "CommentLine", + "value": " await binding in function declaration is not allowed", + "start":415,"end":470,"loc":{"start":{"line":16,"column":0},"end":{"line":16,"column":55}} + }, + { + "type": "CommentLine", + "value": " await binding in class declaration is not allowed", + "start":517,"end":569,"loc":{"start":{"line":18,"column":0},"end":{"line":18,"column":52}} + }, + { + "type": "CommentLine", + "value": " await binding in class expression is not allowed", + "start":611,"end":662,"loc":{"start":{"line":20,"column":0},"end":{"line":20,"column":51}} + }, + { + "type": "CommentLine", + "value": " await in arrow parameters is not allowed", + "start":706,"end":749,"loc":{"start":{"line":22,"column":0},"end":{"line":22,"column":43}} + } + ] } \ No newline at end of file diff --git a/scripts/parser-tests/test262/allowlist.txt b/scripts/parser-tests/test262/allowlist.txt index 9c60566da0c4..8fd07d652582 100644 --- a/scripts/parser-tests/test262/allowlist.txt +++ b/scripts/parser-tests/test262/allowlist.txt @@ -1,22 +1,4 @@ -language/expressions/object/identifier-shorthand-static-init-await-valid.js(default) -language/expressions/object/identifier-shorthand-static-init-await-valid.js(strict mode) language/import/json-invalid.js(default) language/import/json-invalid.js(strict mode) language/import/json-named-bindings.js(default) language/import/json-named-bindings.js(strict mode) -language/statements/class/static-init-await-binding-valid.js(default) -language/statements/class/static-init-await-binding-valid.js(strict mode) -language/statements/const/static-init-await-binding-valid.js(default) -language/statements/const/static-init-await-binding-valid.js(strict mode) -language/statements/function/static-init-await-binding-valid.js(default) -language/statements/function/static-init-await-binding-valid.js(strict mode) -language/statements/let/static-init-await-binding-valid.js(default) -language/statements/let/static-init-await-binding-valid.js(strict mode) -language/statements/try/static-init-await-binding-valid.js(default) -language/statements/try/static-init-await-binding-valid.js(strict mode) -language/statements/variable/dstr/ary-ptrn-elem-id-static-init-await-valid.js(default) -language/statements/variable/dstr/ary-ptrn-elem-id-static-init-await-valid.js(strict mode) -language/statements/variable/dstr/obj-ptrn-elem-id-static-init-await-valid.js(default) -language/statements/variable/dstr/obj-ptrn-elem-id-static-init-await-valid.js(strict mode) -language/statements/variable/static-init-await-binding-valid.js(default) -language/statements/variable/static-init-await-binding-valid.js(strict mode)