Refactor yield await classification (#12230)

* fix: incomplete ParamKind declaration

* refactor: add expression scope handler

* test: update test262 allowlist

* chore: cleanup

* fix: push expression scope for function body

* fix: push new expression scope for initializer and static block

* test: add more test cases

* fix flow error

* refactor: remove unecessary expression scope

* fix: parameter initializer error should not cross expression scope boundary

* chore: cleanup outdated comments

* fix: do not record async arrow error on ParameterDeclaration

* Update packages/babel-parser/src/util/expression-scope.js

Co-authored-by: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>

* polish: clear ancestry declaration error on validate

Co-authored-by: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>
This commit is contained in:
Huáng Jùnliàng
2020-10-26 11:42:02 -04:00
committed by GitHub
parent faaebfe91f
commit 2782a549e9
63 changed files with 1533 additions and 200 deletions

View File

@@ -2,7 +2,7 @@
"type": "File",
"start":0,"end":39,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
"errors": [
"SyntaxError: Can not use 'yield' as identifier inside a generator (2:7)"
"SyntaxError: yield is not allowed in generator parameters (2:7)"
],
"program": {
"type": "Program",
@@ -66,4 +66,4 @@
],
"directives": []
}
}
}

View File

@@ -2,7 +2,7 @@
"type": "File",
"start":0,"end":53,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
"errors": [
"SyntaxError: Can not use 'yield' as identifier inside a generator (2:15)"
"SyntaxError: yield is not allowed in generator parameters (2:15)"
],
"program": {
"type": "Program",
@@ -70,12 +70,12 @@
"start":28,"end":29,"loc":{"start":{"line":2,"column":11},"end":{"line":2,"column":12},"identifierName":"a"},
"name": "a"
},
"computed": false,
"property": {
"type": "Identifier",
"start":30,"end":31,"loc":{"start":{"line":2,"column":13},"end":{"line":2,"column":14},"identifierName":"b"},
"name": "b"
},
"computed": false
}
},
"arguments": [
{

View File

@@ -2,7 +2,7 @@
"type": "File",
"start":0,"end":42,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
"errors": [
"SyntaxError: Can not use 'yield' as identifier inside a generator (2:7)"
"SyntaxError: yield is not allowed in generator parameters (2:7)"
],
"program": {
"type": "Program",

View File

@@ -2,7 +2,7 @@
"type": "File",
"start":0,"end":49,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
"errors": [
"SyntaxError: Can not use 'yield' as identifier inside a generator (2:17)"
"SyntaxError: yield is not allowed in generator parameters (2:17)"
],
"program": {
"type": "Program",

View File

@@ -2,7 +2,7 @@
"type": "File",
"start":0,"end":47,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
"errors": [
"SyntaxError: Can not use 'yield' as identifier inside a generator (2:8)",
"SyntaxError: yield is not allowed in generator parameters (2:8)",
"SyntaxError: Binding invalid left-hand side in function parameter list (2:8)"
],
"program": {

View File

@@ -2,7 +2,7 @@
"type": "File",
"start":0,"end":41,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
"errors": [
"SyntaxError: Can not use 'yield' as identifier inside a generator (2:8)"
"SyntaxError: yield is not allowed in generator parameters (2:8)"
],
"program": {
"type": "Program",
@@ -46,12 +46,12 @@
"right": {
"type": "YieldExpression",
"start":25,"end":30,"loc":{"start":{"line":2,"column":8},"end":{"line":2,"column":13}},
"delegate": false,
"argument": null,
"extra": {
"parenthesized": true,
"parenStart": 24
}
},
"delegate": false,
"argument": null
}
}
],

View File

@@ -2,7 +2,7 @@
"type": "File",
"start":0,"end":35,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
"errors": [
"SyntaxError: Can not use 'yield' as identifier inside a generator (2:3)",
"SyntaxError: yield is not allowed in generator parameters (2:3)",
"SyntaxError: Binding invalid left-hand side in function parameter list (2:3)"
],
"program": {

View File

@@ -2,7 +2,7 @@
"type": "File",
"start":0,"end":38,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
"errors": [
"SyntaxError: Can not use 'yield' as identifier inside a generator (2:3)",
"SyntaxError: yield is not allowed in generator parameters (2:3)",
"SyntaxError: Binding invalid left-hand side in function parameter list (2:3)"
],
"program": {

View File

@@ -2,7 +2,7 @@
"type": "File",
"start":0,"end":41,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
"errors": [
"SyntaxError: Can not use 'yield' as identifier inside a generator (2:9)",
"SyntaxError: yield is not allowed in generator parameters (2:9)",
"SyntaxError: Binding invalid left-hand side in function parameter list (2:9)"
],
"program": {

View File

@@ -0,0 +1 @@
function* g( x = function() { async(yield) }) {};

View File

@@ -0,0 +1,80 @@
{
"type": "File",
"start":0,"end":49,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":49}},
"program": {
"type": "Program",
"start":0,"end":49,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":49}},
"sourceType": "script",
"interpreter": null,
"body": [
{
"type": "FunctionDeclaration",
"start":0,"end":48,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":48}},
"id": {
"type": "Identifier",
"start":10,"end":11,"loc":{"start":{"line":1,"column":10},"end":{"line":1,"column":11},"identifierName":"g"},
"name": "g"
},
"generator": true,
"async": false,
"params": [
{
"type": "AssignmentPattern",
"start":13,"end":44,"loc":{"start":{"line":1,"column":13},"end":{"line":1,"column":44}},
"left": {
"type": "Identifier",
"start":13,"end":14,"loc":{"start":{"line":1,"column":13},"end":{"line":1,"column":14},"identifierName":"x"},
"name": "x"
},
"right": {
"type": "FunctionExpression",
"start":17,"end":44,"loc":{"start":{"line":1,"column":17},"end":{"line":1,"column":44}},
"id": null,
"generator": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start":28,"end":44,"loc":{"start":{"line":1,"column":28},"end":{"line":1,"column":44}},
"body": [
{
"type": "ExpressionStatement",
"start":30,"end":42,"loc":{"start":{"line":1,"column":30},"end":{"line":1,"column":42}},
"expression": {
"type": "CallExpression",
"start":30,"end":42,"loc":{"start":{"line":1,"column":30},"end":{"line":1,"column":42}},
"callee": {
"type": "Identifier",
"start":30,"end":35,"loc":{"start":{"line":1,"column":30},"end":{"line":1,"column":35},"identifierName":"async"},
"name": "async"
},
"arguments": [
{
"type": "Identifier",
"start":36,"end":41,"loc":{"start":{"line":1,"column":36},"end":{"line":1,"column":41},"identifierName":"yield"},
"name": "yield"
}
]
}
}
],
"directives": []
}
}
}
],
"body": {
"type": "BlockStatement",
"start":46,"end":48,"loc":{"start":{"line":1,"column":46},"end":{"line":1,"column":48}},
"body": [],
"directives": []
}
},
{
"type": "EmptyStatement",
"start":48,"end":49,"loc":{"start":{"line":1,"column":48},"end":{"line":1,"column":49}}
}
],
"directives": []
}
}

View File

@@ -2,7 +2,7 @@
"type": "File",
"start":0,"end":36,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":36}},
"errors": [
"SyntaxError: Can not use 'await' as identifier inside an async function (1:20)"
"SyntaxError: Can not use 'await' as identifier inside an async function (1:14)"
],
"program": {
"type": "Program",
@@ -42,6 +42,9 @@
{
"type": "ObjectProperty",
"start":14,"end":19,"loc":{"start":{"line":1,"column":14},"end":{"line":1,"column":19}},
"extra": {
"shorthand": true
},
"method": false,
"key": {
"type": "Identifier",
@@ -54,9 +57,6 @@
"type": "Identifier",
"start":14,"end":19,"loc":{"start":{"line":1,"column":14},"end":{"line":1,"column":19},"identifierName":"await"},
"name": "await"
},
"extra": {
"shorthand": true
}
}
]

View File

@@ -0,0 +1,84 @@
{
"type": "File",
"start":0,"end":50,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":50}},
"program": {
"type": "Program",
"start":0,"end":50,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":50}},
"sourceType": "script",
"interpreter": null,
"body": [
{
"type": "ExpressionStatement",
"start":0,"end":50,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":50}},
"expression": {
"type": "ArrowFunctionExpression",
"start":0,"end":50,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":50}},
"id": null,
"generator": false,
"async": true,
"params": [
{
"type": "AssignmentPattern",
"start":7,"end":43,"loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":43}},
"left": {
"type": "Identifier",
"start":7,"end":8,"loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":8},"identifierName":"x"},
"name": "x"
},
"right": {
"type": "FunctionExpression",
"start":11,"end":43,"loc":{"start":{"line":1,"column":11},"end":{"line":1,"column":43}},
"id": {
"type": "Identifier",
"start":20,"end":21,"loc":{"start":{"line":1,"column":20},"end":{"line":1,"column":21},"identifierName":"f"},
"name": "f"
},
"generator": false,
"async": false,
"params": [
{
"type": "AssignmentPattern",
"start":22,"end":40,"loc":{"start":{"line":1,"column":22},"end":{"line":1,"column":40}},
"left": {
"type": "Identifier",
"start":22,"end":23,"loc":{"start":{"line":1,"column":22},"end":{"line":1,"column":23},"identifierName":"x"},
"name": "x"
},
"right": {
"type": "ClassExpression",
"start":26,"end":40,"loc":{"start":{"line":1,"column":26},"end":{"line":1,"column":40}},
"id": {
"type": "Identifier",
"start":32,"end":37,"loc":{"start":{"line":1,"column":32},"end":{"line":1,"column":37},"identifierName":"await"},
"name": "await"
},
"superClass": null,
"body": {
"type": "ClassBody",
"start":38,"end":40,"loc":{"start":{"line":1,"column":38},"end":{"line":1,"column":40}},
"body": []
}
}
}
],
"body": {
"type": "BlockStatement",
"start":41,"end":43,"loc":{"start":{"line":1,"column":41},"end":{"line":1,"column":43}},
"body": [],
"directives": []
}
}
}
],
"body": {
"type": "BlockStatement",
"start":48,"end":50,"loc":{"start":{"line":1,"column":48},"end":{"line":1,"column":50}},
"body": [],
"directives": []
}
}
}
],
"directives": []
}
}

View File

@@ -0,0 +1 @@
async (x = function() { async(await) }) => {}

View File

@@ -0,0 +1,76 @@
{
"type": "File",
"start":0,"end":45,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":45}},
"program": {
"type": "Program",
"start":0,"end":45,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":45}},
"sourceType": "script",
"interpreter": null,
"body": [
{
"type": "ExpressionStatement",
"start":0,"end":45,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":45}},
"expression": {
"type": "ArrowFunctionExpression",
"start":0,"end":45,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":45}},
"id": null,
"generator": false,
"async": true,
"params": [
{
"type": "AssignmentPattern",
"start":7,"end":38,"loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":38}},
"left": {
"type": "Identifier",
"start":7,"end":8,"loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":8},"identifierName":"x"},
"name": "x"
},
"right": {
"type": "FunctionExpression",
"start":11,"end":38,"loc":{"start":{"line":1,"column":11},"end":{"line":1,"column":38}},
"id": null,
"generator": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start":22,"end":38,"loc":{"start":{"line":1,"column":22},"end":{"line":1,"column":38}},
"body": [
{
"type": "ExpressionStatement",
"start":24,"end":36,"loc":{"start":{"line":1,"column":24},"end":{"line":1,"column":36}},
"expression": {
"type": "CallExpression",
"start":24,"end":36,"loc":{"start":{"line":1,"column":24},"end":{"line":1,"column":36}},
"callee": {
"type": "Identifier",
"start":24,"end":29,"loc":{"start":{"line":1,"column":24},"end":{"line":1,"column":29},"identifierName":"async"},
"name": "async"
},
"arguments": [
{
"type": "Identifier",
"start":30,"end":35,"loc":{"start":{"line":1,"column":30},"end":{"line":1,"column":35},"identifierName":"await"},
"name": "await"
}
]
}
}
],
"directives": []
}
}
}
],
"body": {
"type": "BlockStatement",
"start":43,"end":45,"loc":{"start":{"line":1,"column":43},"end":{"line":1,"column":45}},
"body": [],
"directives": []
}
}
}
],
"directives": []
}
}

View File

@@ -2,7 +2,7 @@
"type": "File",
"start":0,"end":63,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
"errors": [
"SyntaxError: Can not use 'await' as identifier inside an async function (2:23)"
"SyntaxError: await is not allowed in async function parameters (2:23)"
],
"program": {
"type": "Program",

View File

@@ -0,0 +1 @@
function fn(x = async function () { await 1 }) {}

View File

@@ -0,0 +1,73 @@
{
"type": "File",
"start":0,"end":49,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":49}},
"program": {
"type": "Program",
"start":0,"end":49,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":49}},
"sourceType": "script",
"interpreter": null,
"body": [
{
"type": "FunctionDeclaration",
"start":0,"end":49,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":49}},
"id": {
"type": "Identifier",
"start":9,"end":11,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":11},"identifierName":"fn"},
"name": "fn"
},
"generator": false,
"async": false,
"params": [
{
"type": "AssignmentPattern",
"start":12,"end":45,"loc":{"start":{"line":1,"column":12},"end":{"line":1,"column":45}},
"left": {
"type": "Identifier",
"start":12,"end":13,"loc":{"start":{"line":1,"column":12},"end":{"line":1,"column":13},"identifierName":"x"},
"name": "x"
},
"right": {
"type": "FunctionExpression",
"start":16,"end":45,"loc":{"start":{"line":1,"column":16},"end":{"line":1,"column":45}},
"id": null,
"generator": false,
"async": true,
"params": [],
"body": {
"type": "BlockStatement",
"start":34,"end":45,"loc":{"start":{"line":1,"column":34},"end":{"line":1,"column":45}},
"body": [
{
"type": "ExpressionStatement",
"start":36,"end":43,"loc":{"start":{"line":1,"column":36},"end":{"line":1,"column":43}},
"expression": {
"type": "AwaitExpression",
"start":36,"end":43,"loc":{"start":{"line":1,"column":36},"end":{"line":1,"column":43}},
"argument": {
"type": "NumericLiteral",
"start":42,"end":43,"loc":{"start":{"line":1,"column":42},"end":{"line":1,"column":43}},
"extra": {
"rawValue": 1,
"raw": "1"
},
"value": 1
}
}
}
],
"directives": []
}
}
}
],
"body": {
"type": "BlockStatement",
"start":47,"end":49,"loc":{"start":{"line":1,"column":47},"end":{"line":1,"column":49}},
"body": [],
"directives": []
}
}
],
"directives": []
}
}

View File

@@ -0,0 +1,62 @@
{
"type": "File",
"start":0,"end":39,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":39}},
"program": {
"type": "Program",
"start":0,"end":39,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":39}},
"sourceType": "script",
"interpreter": null,
"body": [
{
"type": "FunctionDeclaration",
"start":0,"end":39,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":39}},
"id": {
"type": "Identifier",
"start":9,"end":11,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":11},"identifierName":"fn"},
"name": "fn"
},
"generator": false,
"async": false,
"params": [
{
"type": "AssignmentPattern",
"start":12,"end":35,"loc":{"start":{"line":1,"column":12},"end":{"line":1,"column":35}},
"left": {
"type": "Identifier",
"start":12,"end":13,"loc":{"start":{"line":1,"column":12},"end":{"line":1,"column":13},"identifierName":"x"},
"name": "x"
},
"right": {
"type": "ArrowFunctionExpression",
"start":16,"end":35,"loc":{"start":{"line":1,"column":16},"end":{"line":1,"column":35}},
"id": null,
"generator": false,
"async": true,
"params": [],
"body": {
"type": "AwaitExpression",
"start":28,"end":35,"loc":{"start":{"line":1,"column":28},"end":{"line":1,"column":35}},
"argument": {
"type": "NumericLiteral",
"start":34,"end":35,"loc":{"start":{"line":1,"column":34},"end":{"line":1,"column":35}},
"extra": {
"rawValue": 1,
"raw": "1"
},
"value": 1
}
}
}
}
],
"body": {
"type": "BlockStatement",
"start":37,"end":39,"loc":{"start":{"line":1,"column":37},"end":{"line":1,"column":39}},
"body": [],
"directives": []
}
}
],
"directives": []
}
}

View File

@@ -2,7 +2,7 @@
"type": "File",
"start":0,"end":46,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
"errors": [
"SyntaxError: Can not use 'await' as identifier inside an async function (2:7)"
"SyntaxError: await is not allowed in async function parameters (2:7)"
],
"program": {
"type": "Program",

View File

@@ -2,7 +2,7 @@
"type": "File",
"start":0,"end":52,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
"errors": [
"SyntaxError: Can not use 'await' as identifier inside an async function (2:13)"
"SyntaxError: await is not allowed in async function parameters (2:13)"
],
"program": {
"type": "Program",

View File

@@ -0,0 +1 @@
async ( x = (await) => async (y) => {} );

View File

@@ -0,0 +1,72 @@
{
"type": "File",
"start":0,"end":41,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":41}},
"program": {
"type": "Program",
"start":0,"end":41,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":41}},
"sourceType": "script",
"interpreter": null,
"body": [
{
"type": "ExpressionStatement",
"start":0,"end":41,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":41}},
"expression": {
"type": "CallExpression",
"start":0,"end":40,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":40}},
"callee": {
"type": "Identifier",
"start":0,"end":5,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":5},"identifierName":"async"},
"name": "async"
},
"arguments": [
{
"type": "AssignmentExpression",
"start":8,"end":38,"loc":{"start":{"line":1,"column":8},"end":{"line":1,"column":38}},
"operator": "=",
"left": {
"type": "Identifier",
"start":8,"end":9,"loc":{"start":{"line":1,"column":8},"end":{"line":1,"column":9},"identifierName":"x"},
"name": "x"
},
"right": {
"type": "ArrowFunctionExpression",
"start":12,"end":38,"loc":{"start":{"line":1,"column":12},"end":{"line":1,"column":38}},
"id": null,
"generator": false,
"async": false,
"params": [
{
"type": "Identifier",
"start":13,"end":18,"loc":{"start":{"line":1,"column":13},"end":{"line":1,"column":18},"identifierName":"await"},
"name": "await"
}
],
"body": {
"type": "ArrowFunctionExpression",
"start":23,"end":38,"loc":{"start":{"line":1,"column":23},"end":{"line":1,"column":38}},
"id": null,
"generator": false,
"async": true,
"params": [
{
"type": "Identifier",
"start":30,"end":31,"loc":{"start":{"line":1,"column":30},"end":{"line":1,"column":31},"identifierName":"y"},
"name": "y"
}
],
"body": {
"type": "BlockStatement",
"start":36,"end":38,"loc":{"start":{"line":1,"column":36},"end":{"line":1,"column":38}},
"body": [],
"directives": []
}
}
}
}
]
}
}
],
"directives": []
}
}

View File

@@ -0,0 +1 @@
async ({ x = [ await ], y = { await } }) => {}

View File

@@ -0,0 +1,127 @@
{
"type": "File",
"start":0,"end":46,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":46}},
"errors": [
"SyntaxError: Can not use 'await' as identifier inside an async function (1:15)",
"SyntaxError: Can not use 'await' as identifier inside an async function (1:30)"
],
"program": {
"type": "Program",
"start":0,"end":46,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":46}},
"sourceType": "script",
"interpreter": null,
"body": [
{
"type": "ExpressionStatement",
"start":0,"end":46,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":46}},
"expression": {
"type": "ArrowFunctionExpression",
"start":0,"end":46,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":46}},
"id": null,
"generator": false,
"async": true,
"params": [
{
"type": "ObjectPattern",
"start":7,"end":39,"loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":39}},
"properties": [
{
"type": "ObjectProperty",
"start":9,"end":22,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":22}},
"extra": {
"shorthand": true
},
"method": false,
"key": {
"type": "Identifier",
"start":9,"end":10,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":10},"identifierName":"x"},
"name": "x"
},
"computed": false,
"shorthand": true,
"value": {
"type": "AssignmentPattern",
"start":9,"end":22,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":22}},
"left": {
"type": "Identifier",
"start":9,"end":10,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":10},"identifierName":"x"},
"name": "x"
},
"right": {
"type": "ArrayExpression",
"start":13,"end":22,"loc":{"start":{"line":1,"column":13},"end":{"line":1,"column":22}},
"elements": [
{
"type": "Identifier",
"start":15,"end":20,"loc":{"start":{"line":1,"column":15},"end":{"line":1,"column":20},"identifierName":"await"},
"name": "await"
}
]
}
}
},
{
"type": "ObjectProperty",
"start":24,"end":37,"loc":{"start":{"line":1,"column":24},"end":{"line":1,"column":37}},
"extra": {
"shorthand": true
},
"method": false,
"key": {
"type": "Identifier",
"start":24,"end":25,"loc":{"start":{"line":1,"column":24},"end":{"line":1,"column":25},"identifierName":"y"},
"name": "y"
},
"computed": false,
"shorthand": true,
"value": {
"type": "AssignmentPattern",
"start":24,"end":37,"loc":{"start":{"line":1,"column":24},"end":{"line":1,"column":37}},
"left": {
"type": "Identifier",
"start":24,"end":25,"loc":{"start":{"line":1,"column":24},"end":{"line":1,"column":25},"identifierName":"y"},
"name": "y"
},
"right": {
"type": "ObjectExpression",
"start":28,"end":37,"loc":{"start":{"line":1,"column":28},"end":{"line":1,"column":37}},
"properties": [
{
"type": "ObjectProperty",
"start":30,"end":35,"loc":{"start":{"line":1,"column":30},"end":{"line":1,"column":35}},
"extra": {
"shorthand": true
},
"method": false,
"key": {
"type": "Identifier",
"start":30,"end":35,"loc":{"start":{"line":1,"column":30},"end":{"line":1,"column":35},"identifierName":"await"},
"name": "await"
},
"computed": false,
"shorthand": true,
"value": {
"type": "Identifier",
"start":30,"end":35,"loc":{"start":{"line":1,"column":30},"end":{"line":1,"column":35},"identifierName":"await"},
"name": "await"
}
}
]
}
}
}
]
}
],
"body": {
"type": "BlockStatement",
"start":44,"end":46,"loc":{"start":{"line":1,"column":44},"end":{"line":1,"column":46}},
"body": [],
"directives": []
}
}
}
],
"directives": []
}
}

View File

@@ -2,7 +2,7 @@
"type": "File",
"start":0,"end":38,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":38}},
"errors": [
"SyntaxError: Can not use 'yield' as identifier inside a generator (1:21)"
"SyntaxError: yield is not allowed in generator parameters (1:21)"
],
"program": {
"type": "Program",

View File

@@ -2,7 +2,7 @@
"type": "File",
"start":0,"end":30,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":30}},
"errors": [
"SyntaxError: Can not use 'yield' as identifier inside a generator (1:16)",
"SyntaxError: yield is not allowed in generator parameters (1:16)",
"SyntaxError: Binding invalid left-hand side in function parameter list (1:16)"
],
"program": {

View File

@@ -2,7 +2,7 @@
"type": "File",
"start":0,"end":39,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":39}},
"errors": [
"SyntaxError: Can not use 'yield' as identifier inside a generator (1:25)",
"SyntaxError: yield is not allowed in generator parameters (1:25)",
"SyntaxError: Binding invalid left-hand side in function parameter list (1:25)"
],
"program": {

View File

@@ -2,7 +2,7 @@
"type": "File",
"start":0,"end":35,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":35}},
"errors": [
"SyntaxError: Can not use 'yield' as identifier inside a generator (1:21)"
"SyntaxError: yield is not allowed in generator parameters (1:21)"
],
"program": {
"type": "Program",

View File

@@ -0,0 +1,69 @@
{
"type": "File",
"start":0,"end":33,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":33}},
"program": {
"type": "Program",
"start":0,"end":33,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":33}},
"sourceType": "script",
"interpreter": null,
"body": [
{
"type": "ExpressionStatement",
"start":0,"end":33,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":33}},
"expression": {
"type": "CallExpression",
"start":0,"end":32,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":32}},
"callee": {
"type": "Identifier",
"start":0,"end":5,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":5},"identifierName":"async"},
"name": "async"
},
"arguments": [
{
"type": "AssignmentExpression",
"start":7,"end":31,"loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":31}},
"operator": "=",
"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":31,"loc":{"start":{"line":1,"column":11},"end":{"line":1,"column":31}},
"id": null,
"superClass": null,
"body": {
"type": "ClassBody",
"start":17,"end":31,"loc":{"start":{"line":1,"column":17},"end":{"line":1,"column":31}},
"body": [
{
"type": "ClassPrivateProperty",
"start":19,"end":29,"loc":{"start":{"line":1,"column":19},"end":{"line":1,"column":29}},
"static": false,
"key": {
"type": "PrivateName",
"start":19,"end":21,"loc":{"start":{"line":1,"column":19},"end":{"line":1,"column":21}},
"id": {
"type": "Identifier",
"start":20,"end":21,"loc":{"start":{"line":1,"column":20},"end":{"line":1,"column":21},"identifierName":"x"},
"name": "x"
}
},
"value": {
"type": "Identifier",
"start":24,"end":29,"loc":{"start":{"line":1,"column":24},"end":{"line":1,"column":29},"identifierName":"await"},
"name": "await"
}
}
]
}
}
}
]
}
}
],
"directives": []
}
}

View File

@@ -0,0 +1 @@
async( x = class { #x = await }) => {}

View File

@@ -0,0 +1,72 @@
{
"type": "File",
"start":0,"end":38,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":38}},
"program": {
"type": "Program",
"start":0,"end":38,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":38}},
"sourceType": "script",
"interpreter": null,
"body": [
{
"type": "ExpressionStatement",
"start":0,"end":38,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":38}},
"expression": {
"type": "ArrowFunctionExpression",
"start":0,"end":38,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":38}},
"id": null,
"generator": false,
"async": true,
"params": [
{
"type": "AssignmentPattern",
"start":7,"end":31,"loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":31}},
"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":31,"loc":{"start":{"line":1,"column":11},"end":{"line":1,"column":31}},
"id": null,
"superClass": null,
"body": {
"type": "ClassBody",
"start":17,"end":31,"loc":{"start":{"line":1,"column":17},"end":{"line":1,"column":31}},
"body": [
{
"type": "ClassPrivateProperty",
"start":19,"end":29,"loc":{"start":{"line":1,"column":19},"end":{"line":1,"column":29}},
"static": false,
"key": {
"type": "PrivateName",
"start":19,"end":21,"loc":{"start":{"line":1,"column":19},"end":{"line":1,"column":21}},
"id": {
"type": "Identifier",
"start":20,"end":21,"loc":{"start":{"line":1,"column":20},"end":{"line":1,"column":21},"identifierName":"x"},
"name": "x"
}
},
"value": {
"type": "Identifier",
"start":24,"end":29,"loc":{"start":{"line":1,"column":24},"end":{"line":1,"column":29},"identifierName":"await"},
"name": "await"
}
}
]
}
}
}
],
"body": {
"type": "BlockStatement",
"start":36,"end":38,"loc":{"start":{"line":1,"column":36},"end":{"line":1,"column":38}},
"body": [],
"directives": []
}
}
}
],
"directives": []
}
}

View File

@@ -0,0 +1,3 @@
{
"plugins": ["classPrivateProperties"]
}

View File

@@ -0,0 +1,66 @@
{
"type": "File",
"start":0,"end":33,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":33}},
"program": {
"type": "Program",
"start":0,"end":33,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":33}},
"sourceType": "script",
"interpreter": null,
"body": [
{
"type": "ExpressionStatement",
"start":0,"end":33,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":33}},
"expression": {
"type": "CallExpression",
"start":0,"end":33,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":33}},
"callee": {
"type": "Identifier",
"start":0,"end":5,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":5},"identifierName":"async"},
"name": "async"
},
"arguments": [
{
"type": "AssignmentExpression",
"start":7,"end":32,"loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":32}},
"operator": "=",
"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":32,"loc":{"start":{"line":1,"column":11},"end":{"line":1,"column":32}},
"id": null,
"superClass": null,
"body": {
"type": "ClassBody",
"start":17,"end":32,"loc":{"start":{"line":1,"column":17},"end":{"line":1,"column":32}},
"body": [
{
"type": "ClassProperty",
"start":19,"end":30,"loc":{"start":{"line":1,"column":19},"end":{"line":1,"column":30}},
"static": false,
"computed": true,
"key": {
"type": "Identifier",
"start":20,"end":25,"loc":{"start":{"line":1,"column":20},"end":{"line":1,"column":25},"identifierName":"await"},
"name": "await"
},
"value": {
"type": "Identifier",
"start":29,"end":30,"loc":{"start":{"line":1,"column":29},"end":{"line":1,"column":30},"identifierName":"x"},
"name": "x"
}
}
]
}
}
}
]
}
}
],
"directives": []
}
}

View File

@@ -0,0 +1,93 @@
{
"type": "File",
"start":0,"end":53,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":53}},
"program": {
"type": "Program",
"start":0,"end":53,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":53}},
"sourceType": "script",
"interpreter": null,
"body": [
{
"type": "ExpressionStatement",
"start":0,"end":53,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":53}},
"expression": {
"type": "ArrowFunctionExpression",
"start":0,"end":53,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":53}},
"id": null,
"generator": false,
"async": true,
"params": [
{
"type": "AssignmentPattern",
"start":7,"end":46,"loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":46}},
"left": {
"type": "Identifier",
"start":7,"end":8,"loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":8},"identifierName":"x"},
"name": "x"
},
"right": {
"type": "FunctionExpression",
"start":11,"end":46,"loc":{"start":{"line":1,"column":11},"end":{"line":1,"column":46}},
"id": {
"type": "Identifier",
"start":20,"end":21,"loc":{"start":{"line":1,"column":20},"end":{"line":1,"column":21},"identifierName":"f"},
"name": "f"
},
"generator": false,
"async": false,
"params": [
{
"type": "AssignmentPattern",
"start":22,"end":43,"loc":{"start":{"line":1,"column":22},"end":{"line":1,"column":43}},
"left": {
"type": "Identifier",
"start":22,"end":23,"loc":{"start":{"line":1,"column":22},"end":{"line":1,"column":23},"identifierName":"x"},
"name": "x"
},
"right": {
"type": "ClassExpression",
"start":26,"end":43,"loc":{"start":{"line":1,"column":26},"end":{"line":1,"column":43}},
"id": null,
"superClass": null,
"body": {
"type": "ClassBody",
"start":32,"end":43,"loc":{"start":{"line":1,"column":32},"end":{"line":1,"column":43}},
"body": [
{
"type": "ClassProperty",
"start":34,"end":41,"loc":{"start":{"line":1,"column":34},"end":{"line":1,"column":41}},
"static": false,
"computed": true,
"key": {
"type": "Identifier",
"start":35,"end":40,"loc":{"start":{"line":1,"column":35},"end":{"line":1,"column":40},"identifierName":"await"},
"name": "await"
},
"value": null
}
]
}
}
}
],
"body": {
"type": "BlockStatement",
"start":44,"end":46,"loc":{"start":{"line":1,"column":44},"end":{"line":1,"column":46}},
"body": [],
"directives": []
}
}
}
],
"body": {
"type": "BlockStatement",
"start":51,"end":53,"loc":{"start":{"line":1,"column":51},"end":{"line":1,"column":53}},
"body": [],
"directives": []
}
}
}
],
"directives": []
}
}

View File

@@ -0,0 +1,66 @@
{
"type": "File",
"start":0,"end":32,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":32}},
"program": {
"type": "Program",
"start":0,"end":32,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":32}},
"sourceType": "script",
"interpreter": null,
"body": [
{
"type": "ExpressionStatement",
"start":0,"end":32,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":32}},
"expression": {
"type": "CallExpression",
"start":0,"end":31,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":31}},
"callee": {
"type": "Identifier",
"start":0,"end":5,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":5},"identifierName":"async"},
"name": "async"
},
"arguments": [
{
"type": "AssignmentExpression",
"start":7,"end":30,"loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":30}},
"operator": "=",
"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":30,"loc":{"start":{"line":1,"column":11},"end":{"line":1,"column":30}},
"id": null,
"superClass": null,
"body": {
"type": "ClassBody",
"start":17,"end":30,"loc":{"start":{"line":1,"column":17},"end":{"line":1,"column":30}},
"body": [
{
"type": "ClassProperty",
"start":19,"end":28,"loc":{"start":{"line":1,"column":19},"end":{"line":1,"column":28}},
"static": false,
"key": {
"type": "Identifier",
"start":19,"end":20,"loc":{"start":{"line":1,"column":19},"end":{"line":1,"column":20},"identifierName":"x"},
"name": "x"
},
"computed": false,
"value": {
"type": "Identifier",
"start":23,"end":28,"loc":{"start":{"line":1,"column":23},"end":{"line":1,"column":28},"identifierName":"await"},
"name": "await"
}
}
]
}
}
}
]
}
}
],
"directives": []
}
}

View File

@@ -0,0 +1 @@
async( x = class { [await] = x }) => {}

View File

@@ -0,0 +1,72 @@
{
"type": "File",
"start":0,"end":39,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":39}},
"errors": [
"SyntaxError: Can not use 'await' as identifier inside an async function (1:20)"
],
"program": {
"type": "Program",
"start":0,"end":39,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":39}},
"sourceType": "script",
"interpreter": null,
"body": [
{
"type": "ExpressionStatement",
"start":0,"end":39,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":39}},
"expression": {
"type": "ArrowFunctionExpression",
"start":0,"end":39,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":39}},
"id": null,
"generator": false,
"async": true,
"params": [
{
"type": "AssignmentPattern",
"start":7,"end":32,"loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":32}},
"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":32,"loc":{"start":{"line":1,"column":11},"end":{"line":1,"column":32}},
"id": null,
"superClass": null,
"body": {
"type": "ClassBody",
"start":17,"end":32,"loc":{"start":{"line":1,"column":17},"end":{"line":1,"column":32}},
"body": [
{
"type": "ClassProperty",
"start":19,"end":30,"loc":{"start":{"line":1,"column":19},"end":{"line":1,"column":30}},
"static": false,
"computed": true,
"key": {
"type": "Identifier",
"start":20,"end":25,"loc":{"start":{"line":1,"column":20},"end":{"line":1,"column":25},"identifierName":"await"},
"name": "await"
},
"value": {
"type": "Identifier",
"start":29,"end":30,"loc":{"start":{"line":1,"column":29},"end":{"line":1,"column":30},"identifierName":"x"},
"name": "x"
}
}
]
}
}
}
],
"body": {
"type": "BlockStatement",
"start":37,"end":39,"loc":{"start":{"line":1,"column":37},"end":{"line":1,"column":39}},
"body": [],
"directives": []
}
}
}
],
"directives": []
}
}

View File

@@ -0,0 +1 @@
async( x = class { x = await }) => {}

View File

@@ -0,0 +1,69 @@
{
"type": "File",
"start":0,"end":37,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":37}},
"program": {
"type": "Program",
"start":0,"end":37,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":37}},
"sourceType": "script",
"interpreter": null,
"body": [
{
"type": "ExpressionStatement",
"start":0,"end":37,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":37}},
"expression": {
"type": "ArrowFunctionExpression",
"start":0,"end":37,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":37}},
"id": null,
"generator": false,
"async": true,
"params": [
{
"type": "AssignmentPattern",
"start":7,"end":30,"loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":30}},
"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":30,"loc":{"start":{"line":1,"column":11},"end":{"line":1,"column":30}},
"id": null,
"superClass": null,
"body": {
"type": "ClassBody",
"start":17,"end":30,"loc":{"start":{"line":1,"column":17},"end":{"line":1,"column":30}},
"body": [
{
"type": "ClassProperty",
"start":19,"end":28,"loc":{"start":{"line":1,"column":19},"end":{"line":1,"column":28}},
"static": false,
"key": {
"type": "Identifier",
"start":19,"end":20,"loc":{"start":{"line":1,"column":19},"end":{"line":1,"column":20},"identifierName":"x"},
"name": "x"
},
"computed": false,
"value": {
"type": "Identifier",
"start":23,"end":28,"loc":{"start":{"line":1,"column":23},"end":{"line":1,"column":28},"identifierName":"await"},
"name": "await"
}
}
]
}
}
}
],
"body": {
"type": "BlockStatement",
"start":35,"end":37,"loc":{"start":{"line":1,"column":35},"end":{"line":1,"column":37}},
"body": [],
"directives": []
}
}
}
],
"directives": []
}
}

View File

@@ -0,0 +1,3 @@
{
"plugins": ["classProperties"]
}

View File

@@ -0,0 +1 @@
async (x = class { static { await } }) => {}

View File

@@ -0,0 +1,68 @@
{
"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": []
}
}

View File

@@ -0,0 +1,3 @@
class C {
[await 0] = () => {}
}

View File

@@ -0,0 +1,7 @@
{
"plugins": [
"topLevelAwait",
"classProperties"
],
"sourceType": "module"
}

View File

@@ -0,0 +1,62 @@
{
"type": "File",
"start":0,"end":34,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
"program": {
"type": "Program",
"start":0,"end":34,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
"sourceType": "module",
"interpreter": null,
"body": [
{
"type": "ClassDeclaration",
"start":0,"end":34,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
"id": {
"type": "Identifier",
"start":6,"end":7,"loc":{"start":{"line":1,"column":6},"end":{"line":1,"column":7},"identifierName":"C"},
"name": "C"
},
"superClass": null,
"body": {
"type": "ClassBody",
"start":8,"end":34,"loc":{"start":{"line":1,"column":8},"end":{"line":3,"column":1}},
"body": [
{
"type": "ClassProperty",
"start":12,"end":32,"loc":{"start":{"line":2,"column":2},"end":{"line":2,"column":22}},
"static": false,
"computed": true,
"key": {
"type": "AwaitExpression",
"start":13,"end":20,"loc":{"start":{"line":2,"column":3},"end":{"line":2,"column":10}},
"argument": {
"type": "NumericLiteral",
"start":19,"end":20,"loc":{"start":{"line":2,"column":9},"end":{"line":2,"column":10}},
"extra": {
"rawValue": 0,
"raw": "0"
},
"value": 0
}
},
"value": {
"type": "ArrowFunctionExpression",
"start":24,"end":32,"loc":{"start":{"line":2,"column":14},"end":{"line":2,"column":22}},
"id": null,
"generator": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start":30,"end":32,"loc":{"start":{"line":2,"column":20},"end":{"line":2,"column":22}},
"body": [],
"directives": []
}
}
}
]
}
}
],
"directives": []
}
}