diff --git a/packages/babel-parser/src/parser/error-message.js b/packages/babel-parser/src/parser/error-message.js index 90df3c5f38a2..a6e19810bafa 100644 --- a/packages/babel-parser/src/parser/error-message.js +++ b/packages/babel-parser/src/parser/error-message.js @@ -14,6 +14,8 @@ export const ErrorMessages = Object.freeze({ "Async functions can only be declared at the top level or inside a block", AwaitBindingIdentifier: "Can not use 'await' as identifier inside an async function", + AwaitBindingIdentifierInStaticBlock: + "Can not use 'await' as identifier inside a static block", AwaitExpressionFormalParameter: "await is not allowed in async function parameters", AwaitNotInAsyncContext: diff --git a/packages/babel-parser/src/parser/expression.js b/packages/babel-parser/src/parser/expression.js index 3ed03e0e1a7b..dac215490070 100644 --- a/packages/babel-parser/src/parser/expression.js +++ b/packages/babel-parser/src/parser/expression.js @@ -2297,6 +2297,9 @@ export default class ExpressionParser extends LValParser { if (this.prodParam.hasAwait) { this.raise(startLoc, Errors.AwaitBindingIdentifier); return; + } else if (this.scope.inStaticBlock && !this.scope.inNonArrowFunction) { + this.raise(startLoc, Errors.AwaitBindingIdentifierInStaticBlock); + return; } else { this.expressionScope.recordAsyncArrowParametersError( startLoc, diff --git a/packages/babel-parser/src/parser/statement.js b/packages/babel-parser/src/parser/statement.js index 5827e5154aa8..d97c11236c9e 100644 --- a/packages/babel-parser/src/parser/statement.js +++ b/packages/babel-parser/src/parser/statement.js @@ -20,6 +20,7 @@ import { SCOPE_FUNCTION, SCOPE_OTHER, SCOPE_SIMPLE_CATCH, + SCOPE_STATIC_BLOCK, SCOPE_SUPER, CLASS_ELEMENT_OTHER, CLASS_ELEMENT_INSTANCE_GETTER, @@ -1519,10 +1520,7 @@ export default class StatementParser extends ExpressionParser { ) { this.expectPlugin("classStaticBlock", member.start); // Start a new lexical scope - this.scope.enter(SCOPE_CLASS | SCOPE_SUPER); - // Start a new expression scope, this is required for parsing edge cases like: - // async (x = class { static { await; } }) => {} - this.expressionScope.enter(newExpressionScope()); + this.scope.enter(SCOPE_CLASS | SCOPE_STATIC_BLOCK | SCOPE_SUPER); // Start a new scope with regard to loop labels const oldLabels = this.state.labels; this.state.labels = []; @@ -1532,7 +1530,6 @@ export default class StatementParser extends ExpressionParser { const body = (member.body = []); this.parseBlockOrModuleBlockBody(body, undefined, false, tt.braceR); this.prodParam.exit(); - this.expressionScope.exit(); this.scope.exit(); this.state.labels = oldLabels; classBody.body.push(this.finishNode(member, "StaticBlock")); diff --git a/packages/babel-parser/src/util/scope.js b/packages/babel-parser/src/util/scope.js index b65cb7e0d955..bd3fc8cc37c8 100644 --- a/packages/babel-parser/src/util/scope.js +++ b/packages/babel-parser/src/util/scope.js @@ -8,6 +8,7 @@ import { SCOPE_PROGRAM, SCOPE_VAR, SCOPE_CLASS, + SCOPE_STATIC_BLOCK, BIND_SCOPE_FUNCTION, BIND_SCOPE_VAR, BIND_SCOPE_LEXICAL, @@ -61,6 +62,9 @@ export default class ScopeHandler { get inClass() { return (this.currentThisScope().flags & SCOPE_CLASS) > 0; } + get inStaticBlock() { + return (this.currentThisScope().flags & SCOPE_STATIC_BLOCK) > 0; + } get inNonArrowFunction() { return (this.currentThisScope().flags & SCOPE_FUNCTION) > 0; } diff --git a/packages/babel-parser/src/util/scopeflags.js b/packages/babel-parser/src/util/scopeflags.js index 65c8fd4a608f..f3af9bd3278d 100644 --- a/packages/babel-parser/src/util/scopeflags.js +++ b/packages/babel-parser/src/util/scopeflags.js @@ -2,15 +2,16 @@ // Each scope gets a bitset that may contain these flags // prettier-ignore -export const SCOPE_OTHER = 0b00000000, - SCOPE_PROGRAM = 0b00000001, - SCOPE_FUNCTION = 0b00000010, - SCOPE_ARROW = 0b00000100, - SCOPE_SIMPLE_CATCH = 0b00001000, - SCOPE_SUPER = 0b00010000, - SCOPE_DIRECT_SUPER = 0b00100000, - SCOPE_CLASS = 0b01000000, - SCOPE_TS_MODULE = 0b10000000, +export const SCOPE_OTHER = 0b000000000, + SCOPE_PROGRAM = 0b000000001, + SCOPE_FUNCTION = 0b000000010, + SCOPE_ARROW = 0b000000100, + SCOPE_SIMPLE_CATCH = 0b000001000, + SCOPE_SUPER = 0b000010000, + SCOPE_DIRECT_SUPER = 0b000100000, + SCOPE_CLASS = 0b001000000, + SCOPE_STATIC_BLOCK = 0b010000000, + SCOPE_TS_MODULE = 0b100000000, SCOPE_VAR = SCOPE_PROGRAM | SCOPE_FUNCTION | SCOPE_TS_MODULE; export type ScopeFlags = @@ -22,7 +23,8 @@ export type ScopeFlags = | typeof SCOPE_SIMPLE_CATCH | typeof SCOPE_SUPER | typeof SCOPE_DIRECT_SUPER - | typeof SCOPE_CLASS; + | typeof SCOPE_CLASS + | typeof SCOPE_STATIC_BLOCK; // These flags are meant to be _only_ used inside the Scope class (or subclasses). // prettier-ignore 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 new file mode 100644 index 000000000000..d35f8544e20c --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/class-static-block/await-binding-in-function-in-static-block/input.js @@ -0,0 +1,9 @@ +var C; + +C = class { static { function f() { await } } }; + +C = class { static { function f(await) {} } }; + +C = class { static { function f(x = await) {} } }; + +C = class { static { function f({ [await]: x }) {} } }; 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 new file mode 100644 index 000000000000..c23689913ca4 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/class-static-block/await-binding-in-static-block/input.js @@ -0,0 +1,23 @@ +var C; + +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 } }) => {}; 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 new file mode 100644 index 000000000000..19bbde57a4c3 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/class-static-block/await-binding-in-static-block/output.json @@ -0,0 +1,678 @@ +{ + "type": "File", + "start":0,"end":485,"loc":{"start":{"line":1,"column":0},"end":{"line":23,"column":45}}, + "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 (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)" + ], + "program": { + "type": "Program", + "start":0,"end":485,"loc":{"start":{"line":1,"column":0},"end":{"line":23,"column":45}}, + "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":39,"loc":{"start":{"line":3,"column":0},"end":{"line":3,"column":31}}, + "expression": { + "type": "AssignmentExpression", + "start":8,"end":38,"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"}, + "name": "C" + }, + "right": { + "type": "ClassExpression", + "start":12,"end":38,"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}}, + "body": [ + { + "type": "StaticBlock", + "start":20,"end":36,"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}}, + "expression": { + "type": "Identifier", + "start":29,"end":34,"loc":{"start":{"line":3,"column":21},"end":{"line":3,"column":26},"identifierName":"await"}, + "name": "await" + } + } + ] + } + ] + } + } + } + }, + { + "type": "ExpressionStatement", + "start":41,"end":78,"loc":{"start":{"line":5,"column":0},"end":{"line":5,"column":37}}, + "expression": { + "type": "AssignmentExpression", + "start":41,"end":77,"loc":{"start":{"line":5,"column":0},"end":{"line":5,"column":36}}, + "operator": "=", + "left": { + "type": "Identifier", + "start":41,"end":42,"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}}, + "id": null, + "superClass": null, + "body": { + "type": "ClassBody", + "start":51,"end":77,"loc":{"start":{"line":5,"column":10},"end":{"line":5,"column":36}}, + "body": [ + { + "type": "StaticBlock", + "start":53,"end":75,"loc":{"start":{"line":5,"column":12},"end":{"line":5,"column":34}}, + "body": [ + { + "type": "ExpressionStatement", + "start":62,"end":73,"loc":{"start":{"line":5,"column":21},"end":{"line":5,"column":32}}, + "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": "ExpressionStatement", + "start":80,"end":119,"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}}, + "operator": "=", + "left": { + "type": "Identifier", + "start":80,"end":81,"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}}, + "id": null, + "superClass": null, + "body": { + "type": "ClassBody", + "start":90,"end":118,"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}}, + "body": [ + { + "type": "ExpressionStatement", + "start":101,"end":114,"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": "Identifier", + "start":102,"end":107,"loc":{"start":{"line":7,"column":22},"end":{"line":7,"column":27},"identifierName":"await"}, + "name": "await" + } + ], + "body": { + "type": "BlockStatement", + "start":112,"end":114,"loc":{"start":{"line":7,"column":32},"end":{"line":7,"column":34}}, + "body": [], + "directives": [] + } + } + } + ] + } + ] + } + } + } + }, + { + "type": "ExpressionStatement", + "start":121,"end":154,"loc":{"start":{"line":9,"column":0},"end":{"line":9,"column":33}}, + "expression": { + "type": "AssignmentExpression", + "start":121,"end":153,"loc":{"start":{"line":9,"column":0},"end":{"line":9,"column":32}}, + "operator": "=", + "left": { + "type": "Identifier", + "start":121,"end":122,"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}}, + "id": null, + "superClass": null, + "body": { + "type": "ClassBody", + "start":131,"end":153,"loc":{"start":{"line":9,"column":10},"end":{"line":9,"column":32}}, + "body": [ + { + "type": "StaticBlock", + "start":133,"end":151,"loc":{"start":{"line":9,"column":12},"end":{"line":9,"column":30}}, + "body": [ + { + "type": "ExpressionStatement", + "start":142,"end":149,"loc":{"start":{"line":9,"column":21},"end":{"line":9,"column":28}}, + "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 + }, + "name": "await" + } + } + ] + } + ] + } + } + } + }, + { + "type": "ExpressionStatement", + "start":156,"end":201,"loc":{"start":{"line":11,"column":0},"end":{"line":11,"column":45}}, + "expression": { + "type": "AssignmentExpression", + "start":156,"end":200,"loc":{"start":{"line":11,"column":0},"end":{"line":11,"column":44}}, + "operator": "=", + "left": { + "type": "Identifier", + "start":156,"end":157,"loc":{"start":{"line":11,"column":0},"end":{"line":11,"column":1},"identifierName":"C"}, + "name": "C" + }, + "right": { + "type": "ClassExpression", + "start":160,"end":200,"loc":{"start":{"line":11,"column":4},"end":{"line":11,"column":44}}, + "id": null, + "superClass": null, + "body": { + "type": "ClassBody", + "start":166,"end":200,"loc":{"start":{"line":11,"column":10},"end":{"line":11,"column":44}}, + "body": [ + { + "type": "StaticBlock", + "start":168,"end":198,"loc":{"start":{"line":11,"column":12},"end":{"line":11,"column":42}}, + "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": "ExpressionStatement", + "start":203,"end":242,"loc":{"start":{"line":13,"column":0},"end":{"line":13,"column":39}}, + "expression": { + "type": "AssignmentExpression", + "start":203,"end":241,"loc":{"start":{"line":13,"column":0},"end":{"line":13,"column":38}}, + "operator": "=", + "left": { + "type": "Identifier", + "start":203,"end":204,"loc":{"start":{"line":13,"column":0},"end":{"line":13,"column":1},"identifierName":"C"}, + "name": "C" + }, + "right": { + "type": "ClassExpression", + "start":207,"end":241,"loc":{"start":{"line":13,"column":4},"end":{"line":13,"column":38}}, + "id": null, + "superClass": null, + "body": { + "type": "ClassBody", + "start":213,"end":241,"loc":{"start":{"line":13,"column":10},"end":{"line":13,"column":38}}, + "body": [ + { + "type": "StaticBlock", + "start":215,"end":239,"loc":{"start":{"line":13,"column":12},"end":{"line":13,"column":36}}, + "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": "Identifier", + "start":231,"end":236,"loc":{"start":{"line":13,"column":28},"end":{"line":13,"column":33},"identifierName":"await"}, + "name": "await" + } + ] + } + } + ] + } + ] + } + } + } + }, + { + "type": "ExpressionStatement", + "start":244,"end":291,"loc":{"start":{"line":15,"column":0},"end":{"line":15,"column":47}}, + "expression": { + "type": "AssignmentExpression", + "start":244,"end":290,"loc":{"start":{"line":15,"column":0},"end":{"line":15,"column":46}}, + "operator": "=", + "left": { + "type": "Identifier", + "start":244,"end":245,"loc":{"start":{"line":15,"column":0},"end":{"line":15,"column":1},"identifierName":"C"}, + "name": "C" + }, + "right": { + "type": "ClassExpression", + "start":248,"end":290,"loc":{"start":{"line":15,"column":4},"end":{"line":15,"column":46}}, + "id": null, + "superClass": null, + "body": { + "type": "ClassBody", + "start":254,"end":290,"loc":{"start":{"line":15,"column":10},"end":{"line":15,"column":46}}, + "body": [ + { + "type": "StaticBlock", + "start":256,"end":288,"loc":{"start":{"line":15,"column":12},"end":{"line":15,"column":44}}, + "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": "ExpressionStatement", + "start":293,"end":334,"loc":{"start":{"line":17,"column":0},"end":{"line":17,"column":41}}, + "expression": { + "type": "AssignmentExpression", + "start":293,"end":333,"loc":{"start":{"line":17,"column":0},"end":{"line":17,"column":40}}, + "operator": "=", + "left": { + "type": "Identifier", + "start":293,"end":294,"loc":{"start":{"line":17,"column":0},"end":{"line":17,"column":1},"identifierName":"C"}, + "name": "C" + }, + "right": { + "type": "ClassExpression", + "start":297,"end":333,"loc":{"start":{"line":17,"column":4},"end":{"line":17,"column":40}}, + "id": null, + "superClass": null, + "body": { + "type": "ClassBody", + "start":303,"end":333,"loc":{"start":{"line":17,"column":10},"end":{"line":17,"column":40}}, + "body": [ + { + "type": "StaticBlock", + "start":305,"end":331,"loc":{"start":{"line":17,"column":12},"end":{"line":17,"column":38}}, + "body": [ + { + "type": "ExpressionStatement", + "start":314,"end":329,"loc":{"start":{"line":17,"column":21},"end":{"line":17,"column":36}}, + "expression": { + "type": "ObjectExpression", + "start":315,"end":328,"loc":{"start":{"line":17,"column":22},"end":{"line":17,"column":35}}, + "extra": { + "parenthesized": true, + "parenStart": 314 + }, + "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" + } + } + ] + } + } + ] + } + ] + } + } + } + }, + { + "type": "ExpressionStatement", + "start":336,"end":389,"loc":{"start":{"line":19,"column":0},"end":{"line":19,"column":53}}, + "expression": { + "type": "AssignmentExpression", + "start":336,"end":388,"loc":{"start":{"line":19,"column":0},"end":{"line":19,"column":52}}, + "operator": "=", + "left": { + "type": "Identifier", + "start":336,"end":337,"loc":{"start":{"line":19,"column":0},"end":{"line":19,"column":1},"identifierName":"C"}, + "name": "C" + }, + "right": { + "type": "ClassExpression", + "start":340,"end":388,"loc":{"start":{"line":19,"column":4},"end":{"line":19,"column":52}}, + "id": null, + "superClass": null, + "body": { + "type": "ClassBody", + "start":346,"end":388,"loc":{"start":{"line":19,"column":10},"end":{"line":19,"column":52}}, + "body": [ + { + "type": "StaticBlock", + "start":348,"end":386,"loc":{"start":{"line":19,"column":12},"end":{"line":19,"column":50}}, + "body": [ + { + "type": "ExpressionStatement", + "start":357,"end":384,"loc":{"start":{"line":19,"column":21},"end":{"line":19,"column":48}}, + "expression": { + "type": "ArrowFunctionExpression", + "start":357,"end":384,"loc":{"start":{"line":19,"column":21},"end":{"line":19,"column":48}}, + "id": null, + "generator": false, + "async": true, + "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" + } + } + ] + } + ], + "body": { + "type": "BlockStatement", + "start":382,"end":384,"loc":{"start":{"line":19,"column":46},"end":{"line":19,"column":48}}, + "body": [], + "directives": [] + } + } + } + ] + } + ] + } + } + } + }, + { + "type": "ExpressionStatement", + "start":391,"end":438,"loc":{"start":{"line":21,"column":0},"end":{"line":21,"column":47}}, + "expression": { + "type": "AssignmentExpression", + "start":391,"end":437,"loc":{"start":{"line":21,"column":0},"end":{"line":21,"column":46}}, + "operator": "=", + "left": { + "type": "Identifier", + "start":391,"end":392,"loc":{"start":{"line":21,"column":0},"end":{"line":21,"column":1},"identifierName":"C"}, + "name": "C" + }, + "right": { + "type": "ClassExpression", + "start":395,"end":437,"loc":{"start":{"line":21,"column":4},"end":{"line":21,"column":46}}, + "id": null, + "superClass": null, + "body": { + "type": "ClassBody", + "start":401,"end":437,"loc":{"start":{"line":21,"column":10},"end":{"line":21,"column":46}}, + "body": [ + { + "type": "StaticBlock", + "start":403,"end":435,"loc":{"start":{"line":21,"column":12},"end":{"line":21,"column":44}}, + "body": [ + { + "type": "ExpressionStatement", + "start":412,"end":433,"loc":{"start":{"line":21,"column":21},"end":{"line":21,"column":42}}, + "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": "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": "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": [] + } + } + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/experimental/class-static-block/await-in-static-block-in-params-of-async-arrow/input.js b/packages/babel-parser/test/fixtures/experimental/class-static-block/await-in-static-block-in-params-of-async-arrow/input.js deleted file mode 100644 index ce6aeee6df45..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/class-static-block/await-in-static-block-in-params-of-async-arrow/input.js +++ /dev/null @@ -1 +0,0 @@ -async (x = class { static { await } }) => {} diff --git a/packages/babel-parser/test/fixtures/experimental/class-static-block/await-in-static-block-in-params-of-async-arrow/output.json b/packages/babel-parser/test/fixtures/experimental/class-static-block/await-in-static-block-in-params-of-async-arrow/output.json deleted file mode 100644 index cd6fcce3a7e6..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/class-static-block/await-in-static-block-in-params-of-async-arrow/output.json +++ /dev/null @@ -1,68 +0,0 @@ -{ - "type": "File", - "start":0,"end":44,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":44}}, - "program": { - "type": "Program", - "start":0,"end":44,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":44}}, - "sourceType": "script", - "interpreter": null, - "body": [ - { - "type": "ExpressionStatement", - "start":0,"end":44,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":44}}, - "expression": { - "type": "ArrowFunctionExpression", - "start":0,"end":44,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":44}}, - "id": null, - "generator": false, - "async": true, - "params": [ - { - "type": "AssignmentPattern", - "start":7,"end":37,"loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":37}}, - "left": { - "type": "Identifier", - "start":7,"end":8,"loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":8},"identifierName":"x"}, - "name": "x" - }, - "right": { - "type": "ClassExpression", - "start":11,"end":37,"loc":{"start":{"line":1,"column":11},"end":{"line":1,"column":37}}, - "id": null, - "superClass": null, - "body": { - "type": "ClassBody", - "start":17,"end":37,"loc":{"start":{"line":1,"column":17},"end":{"line":1,"column":37}}, - "body": [ - { - "type": "StaticBlock", - "start":19,"end":35,"loc":{"start":{"line":1,"column":19},"end":{"line":1,"column":35}}, - "body": [ - { - "type": "ExpressionStatement", - "start":28,"end":33,"loc":{"start":{"line":1,"column":28},"end":{"line":1,"column":33}}, - "expression": { - "type": "Identifier", - "start":28,"end":33,"loc":{"start":{"line":1,"column":28},"end":{"line":1,"column":33},"identifierName":"await"}, - "name": "await" - } - } - ] - } - ] - } - } - } - ], - "body": { - "type": "BlockStatement", - "start":42,"end":44,"loc":{"start":{"line":1,"column":42},"end":{"line":1,"column":44}}, - "body": [], - "directives": [] - } - } - } - ], - "directives": [] - } -} \ No newline at end of file