diff --git a/src/parser/expression.js b/src/parser/expression.js index 1e503bea18..891ab4d3cf 100644 --- a/src/parser/expression.js +++ b/src/parser/expression.js @@ -750,7 +750,7 @@ pp.parseObj = function (isPattern, refShorthandDefaultPos) { if (isGenerator) this.unexpected(); let asyncId = this.parseIdentifier(); - if (this.match(tt.colon) || this.match(tt.parenL) || this.match(tt.braceR)) { + if (this.match(tt.colon) || this.match(tt.parenL) || this.match(tt.braceR) || this.match(tt.eq)) { prop.key = asyncId; } else { isAsync = true; diff --git a/test/fixtures/es2017/async-functions/27/actual.js b/test/fixtures/es2017/async-functions/27/actual.js new file mode 100644 index 0000000000..16862c8573 --- /dev/null +++ b/test/fixtures/es2017/async-functions/27/actual.js @@ -0,0 +1 @@ +const foo = ({ async = true }) => {}; diff --git a/test/fixtures/es2017/async-functions/27/expected.json b/test/fixtures/es2017/async-functions/27/expected.json new file mode 100644 index 0000000000..ccacb5ffa3 --- /dev/null +++ b/test/fixtures/es2017/async-functions/27/expected.json @@ -0,0 +1,224 @@ +{ + "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", + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 37, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 37 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 6, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "id": { + "type": "Identifier", + "start": 6, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 9 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "init": { + "type": "ArrowFunctionExpression", + "start": 12, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "id": null, + "generator": false, + "expression": false, + "async": false, + "params": [ + { + "type": "ObjectPattern", + "start": 13, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "properties": [ + { + "type": "ObjectProperty", + "start": 15, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "method": false, + "shorthand": true, + "key": { + "type": "Identifier", + "start": 15, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 20 + }, + "identifierName": "async" + }, + "name": "async" + }, + "value": { + "type": "AssignmentPattern", + "start": 15, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "left": { + "type": "Identifier", + "start": 15, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 20 + }, + "identifierName": "async" + }, + "name": "async" + }, + "right": { + "type": "BooleanLiteral", + "start": 23, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 23 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "value": true + } + }, + "extra": { + "shorthand": true + } + } + ] + } + ], + "body": { + "type": "BlockStatement", + "start": 34, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 34 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "body": [], + "directives": [] + } + } + } + ], + "kind": "const" + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/test/fixtures/es2017/async-functions/28/actual.js b/test/fixtures/es2017/async-functions/28/actual.js new file mode 100644 index 0000000000..d55db6c6ea --- /dev/null +++ b/test/fixtures/es2017/async-functions/28/actual.js @@ -0,0 +1 @@ +const foo = ({ async: bar }) => {}; diff --git a/test/fixtures/es2017/async-functions/28/expected.json b/test/fixtures/es2017/async-functions/28/expected.json new file mode 100644 index 0000000000..bde4093e1f --- /dev/null +++ b/test/fixtures/es2017/async-functions/28/expected.json @@ -0,0 +1,190 @@ +{ + "type": "File", + "start": 0, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 35 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 35 + } + }, + "sourceType": "script", + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 35 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 6, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 34 + } + }, + "id": { + "type": "Identifier", + "start": 6, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 9 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "init": { + "type": "ArrowFunctionExpression", + "start": 12, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 34 + } + }, + "id": null, + "generator": false, + "expression": false, + "async": false, + "params": [ + { + "type": "ObjectPattern", + "start": 13, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "properties": [ + { + "type": "ObjectProperty", + "start": 15, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "method": false, + "shorthand": false, + "key": { + "type": "Identifier", + "start": 15, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 20 + }, + "identifierName": "async" + }, + "name": "async" + }, + "value": { + "type": "Identifier", + "start": 22, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 22 + }, + "end": { + "line": 1, + "column": 25 + }, + "identifierName": "bar" + }, + "name": "bar" + } + } + ] + } + ], + "body": { + "type": "BlockStatement", + "start": 32, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 34 + } + }, + "body": [], + "directives": [] + } + } + } + ], + "kind": "const" + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/test/fixtures/es2017/async-functions/29/actual.js b/test/fixtures/es2017/async-functions/29/actual.js new file mode 100644 index 0000000000..4cb7eab451 --- /dev/null +++ b/test/fixtures/es2017/async-functions/29/actual.js @@ -0,0 +1 @@ +const foo = function({ async = true }) {}; diff --git a/test/fixtures/es2017/async-functions/29/expected.json b/test/fixtures/es2017/async-functions/29/expected.json new file mode 100644 index 0000000000..2b1b294507 --- /dev/null +++ b/test/fixtures/es2017/async-functions/29/expected.json @@ -0,0 +1,225 @@ +{ + "type": "File", + "start": 0, + "end": 42, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 42 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 42, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 42 + } + }, + "sourceType": "script", + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 42, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 42 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 6, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 41 + } + }, + "id": { + "type": "Identifier", + "start": 6, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 9 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "init": { + "type": "FunctionExpression", + "start": 12, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 41 + } + }, + "id": null, + "generator": false, + "expression": false, + "async": false, + "params": [ + { + "type": "ObjectPattern", + "start": 21, + "end": 37, + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 1, + "column": 37 + } + }, + "properties": [ + { + "type": "ObjectProperty", + "start": 23, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 23 + }, + "end": { + "line": 1, + "column": 35 + } + }, + "method": false, + "shorthand": true, + "computed": false, + "key": { + "type": "Identifier", + "start": 23, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 23 + }, + "end": { + "line": 1, + "column": 28 + }, + "identifierName": "async" + }, + "name": "async" + }, + "value": { + "type": "AssignmentPattern", + "start": 23, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 23 + }, + "end": { + "line": 1, + "column": 35 + } + }, + "left": { + "type": "Identifier", + "start": 23, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 23 + }, + "end": { + "line": 1, + "column": 28 + }, + "identifierName": "async" + }, + "name": "async" + }, + "right": { + "type": "BooleanLiteral", + "start": 31, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 31 + }, + "end": { + "line": 1, + "column": 35 + } + }, + "value": true + } + }, + "extra": { + "shorthand": true + } + } + ] + } + ], + "body": { + "type": "BlockStatement", + "start": 39, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 39 + }, + "end": { + "line": 1, + "column": 41 + } + }, + "body": [], + "directives": [] + } + } + } + ], + "kind": "const" + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/test/fixtures/es2017/async-functions/30/actual.js b/test/fixtures/es2017/async-functions/30/actual.js new file mode 100644 index 0000000000..157253a66a --- /dev/null +++ b/test/fixtures/es2017/async-functions/30/actual.js @@ -0,0 +1 @@ +const foo = function({ async: bar }) {}; diff --git a/test/fixtures/es2017/async-functions/30/expected.json b/test/fixtures/es2017/async-functions/30/expected.json new file mode 100644 index 0000000000..1aea157ede --- /dev/null +++ b/test/fixtures/es2017/async-functions/30/expected.json @@ -0,0 +1,191 @@ +{ + "type": "File", + "start": 0, + "end": 40, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 40 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 40, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 40 + } + }, + "sourceType": "script", + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 40, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 40 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 6, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "id": { + "type": "Identifier", + "start": 6, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 9 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "init": { + "type": "FunctionExpression", + "start": 12, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "id": null, + "generator": false, + "expression": false, + "async": false, + "params": [ + { + "type": "ObjectPattern", + "start": 21, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 1, + "column": 35 + } + }, + "properties": [ + { + "type": "ObjectProperty", + "start": 23, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 23 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "method": false, + "shorthand": false, + "computed": false, + "key": { + "type": "Identifier", + "start": 23, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 23 + }, + "end": { + "line": 1, + "column": 28 + }, + "identifierName": "async" + }, + "name": "async" + }, + "value": { + "type": "Identifier", + "start": 30, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 30 + }, + "end": { + "line": 1, + "column": 33 + }, + "identifierName": "bar" + }, + "name": "bar" + } + } + ] + } + ], + "body": { + "type": "BlockStatement", + "start": 37, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 37 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "body": [], + "directives": [] + } + } + } + ], + "kind": "const" + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/test/fixtures/es2017/async-functions/31/actual.js b/test/fixtures/es2017/async-functions/31/actual.js new file mode 100644 index 0000000000..3f1a937f6a --- /dev/null +++ b/test/fixtures/es2017/async-functions/31/actual.js @@ -0,0 +1,3 @@ +const foo = async ({ async: bar }) => { + await baz; +}; diff --git a/test/fixtures/es2017/async-functions/31/expected.json b/test/fixtures/es2017/async-functions/31/expected.json new file mode 100644 index 0000000000..92d6c16d7a --- /dev/null +++ b/test/fixtures/es2017/async-functions/31/expected.json @@ -0,0 +1,238 @@ +{ + "type": "File", + "start": 0, + "end": 55, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 2 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 55, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 2 + } + }, + "sourceType": "script", + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 55, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 2 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 6, + "end": 54, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 6, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 9 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "init": { + "type": "ArrowFunctionExpression", + "start": 12, + "end": 54, + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "id": null, + "generator": false, + "expression": false, + "async": true, + "params": [ + { + "type": "ObjectPattern", + "start": 19, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "properties": [ + { + "type": "ObjectProperty", + "start": 21, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "method": false, + "shorthand": false, + "key": { + "type": "Identifier", + "start": 21, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 1, + "column": 26 + }, + "identifierName": "async" + }, + "name": "async" + }, + "value": { + "type": "Identifier", + "start": 28, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 28 + }, + "end": { + "line": 1, + "column": 31 + }, + "identifierName": "bar" + }, + "name": "bar" + } + } + ] + } + ], + "body": { + "type": "BlockStatement", + "start": 38, + "end": 54, + "loc": { + "start": { + "line": 1, + "column": 38 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 42, + "end": 52, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 12 + } + }, + "expression": { + "type": "AwaitExpression", + "start": 42, + "end": 51, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 11 + } + }, + "argument": { + "type": "Identifier", + "start": 48, + "end": 51, + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 11 + }, + "identifierName": "baz" + }, + "name": "baz" + } + } + } + ], + "directives": [] + } + } + } + ], + "kind": "const" + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/test/fixtures/es2017/async-functions/32/actual.js b/test/fixtures/es2017/async-functions/32/actual.js new file mode 100644 index 0000000000..8c1582dbd1 --- /dev/null +++ b/test/fixtures/es2017/async-functions/32/actual.js @@ -0,0 +1,3 @@ +const foo = async ({ async = bar }) => { + await baz; +}; diff --git a/test/fixtures/es2017/async-functions/32/expected.json b/test/fixtures/es2017/async-functions/32/expected.json new file mode 100644 index 0000000000..8c778ed135 --- /dev/null +++ b/test/fixtures/es2017/async-functions/32/expected.json @@ -0,0 +1,273 @@ +{ + "type": "File", + "start": 0, + "end": 56, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 2 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 56, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 2 + } + }, + "sourceType": "script", + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 56, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 2 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 6, + "end": 55, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 6, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 9 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "init": { + "type": "ArrowFunctionExpression", + "start": 12, + "end": 55, + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "id": null, + "generator": false, + "expression": false, + "async": true, + "params": [ + { + "type": "ObjectPattern", + "start": 19, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 34 + } + }, + "properties": [ + { + "type": "ObjectProperty", + "start": 21, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "method": false, + "shorthand": true, + "key": { + "type": "Identifier", + "start": 21, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 1, + "column": 26 + }, + "identifierName": "async" + }, + "name": "async" + }, + "value": { + "type": "AssignmentPattern", + "start": 21, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "left": { + "type": "Identifier", + "start": 21, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 1, + "column": 26 + }, + "identifierName": "async" + }, + "name": "async" + }, + "right": { + "type": "Identifier", + "start": 29, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 29 + }, + "end": { + "line": 1, + "column": 32 + }, + "identifierName": "bar" + }, + "name": "bar" + } + }, + "extra": { + "shorthand": true + } + } + ] + } + ], + "body": { + "type": "BlockStatement", + "start": 39, + "end": 55, + "loc": { + "start": { + "line": 1, + "column": 39 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 43, + "end": 53, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 12 + } + }, + "expression": { + "type": "AwaitExpression", + "start": 43, + "end": 52, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 11 + } + }, + "argument": { + "type": "Identifier", + "start": 49, + "end": 52, + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 11 + }, + "identifierName": "baz" + }, + "name": "baz" + } + } + } + ], + "directives": [] + } + } + } + ], + "kind": "const" + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/test/fixtures/es2017/async-functions/33/actual.js b/test/fixtures/es2017/async-functions/33/actual.js new file mode 100644 index 0000000000..6fc1ca75ab --- /dev/null +++ b/test/fixtures/es2017/async-functions/33/actual.js @@ -0,0 +1,3 @@ +const foo = async function({ async: bar }) { + await baz; +}; diff --git a/test/fixtures/es2017/async-functions/33/expected.json b/test/fixtures/es2017/async-functions/33/expected.json new file mode 100644 index 0000000000..a12a5ebf50 --- /dev/null +++ b/test/fixtures/es2017/async-functions/33/expected.json @@ -0,0 +1,239 @@ +{ + "type": "File", + "start": 0, + "end": 60, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 2 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 60, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 2 + } + }, + "sourceType": "script", + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 60, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 2 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 6, + "end": 59, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 6, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 9 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "init": { + "type": "FunctionExpression", + "start": 12, + "end": 59, + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "id": null, + "generator": false, + "expression": false, + "async": true, + "params": [ + { + "type": "ObjectPattern", + "start": 27, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 27 + }, + "end": { + "line": 1, + "column": 41 + } + }, + "properties": [ + { + "type": "ObjectProperty", + "start": 29, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 29 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "method": false, + "shorthand": false, + "computed": false, + "key": { + "type": "Identifier", + "start": 29, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 29 + }, + "end": { + "line": 1, + "column": 34 + }, + "identifierName": "async" + }, + "name": "async" + }, + "value": { + "type": "Identifier", + "start": 36, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 36 + }, + "end": { + "line": 1, + "column": 39 + }, + "identifierName": "bar" + }, + "name": "bar" + } + } + ] + } + ], + "body": { + "type": "BlockStatement", + "start": 43, + "end": 59, + "loc": { + "start": { + "line": 1, + "column": 43 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 47, + "end": 57, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 12 + } + }, + "expression": { + "type": "AwaitExpression", + "start": 47, + "end": 56, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 11 + } + }, + "argument": { + "type": "Identifier", + "start": 53, + "end": 56, + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 11 + }, + "identifierName": "baz" + }, + "name": "baz" + } + } + } + ], + "directives": [] + } + } + } + ], + "kind": "const" + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/test/fixtures/es2017/async-functions/34/actual.js b/test/fixtures/es2017/async-functions/34/actual.js new file mode 100644 index 0000000000..10aaa3c5fd --- /dev/null +++ b/test/fixtures/es2017/async-functions/34/actual.js @@ -0,0 +1,3 @@ +const foo = async function({ async = bar }) { + await baz; +}; diff --git a/test/fixtures/es2017/async-functions/34/expected.json b/test/fixtures/es2017/async-functions/34/expected.json new file mode 100644 index 0000000000..ba2325893d --- /dev/null +++ b/test/fixtures/es2017/async-functions/34/expected.json @@ -0,0 +1,274 @@ +{ + "type": "File", + "start": 0, + "end": 61, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 2 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 61, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 2 + } + }, + "sourceType": "script", + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 61, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 2 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 6, + "end": 60, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 6, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 9 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "init": { + "type": "FunctionExpression", + "start": 12, + "end": 60, + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "id": null, + "generator": false, + "expression": false, + "async": true, + "params": [ + { + "type": "ObjectPattern", + "start": 27, + "end": 42, + "loc": { + "start": { + "line": 1, + "column": 27 + }, + "end": { + "line": 1, + "column": 42 + } + }, + "properties": [ + { + "type": "ObjectProperty", + "start": 29, + "end": 40, + "loc": { + "start": { + "line": 1, + "column": 29 + }, + "end": { + "line": 1, + "column": 40 + } + }, + "method": false, + "shorthand": true, + "computed": false, + "key": { + "type": "Identifier", + "start": 29, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 29 + }, + "end": { + "line": 1, + "column": 34 + }, + "identifierName": "async" + }, + "name": "async" + }, + "value": { + "type": "AssignmentPattern", + "start": 29, + "end": 40, + "loc": { + "start": { + "line": 1, + "column": 29 + }, + "end": { + "line": 1, + "column": 40 + } + }, + "left": { + "type": "Identifier", + "start": 29, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 29 + }, + "end": { + "line": 1, + "column": 34 + }, + "identifierName": "async" + }, + "name": "async" + }, + "right": { + "type": "Identifier", + "start": 37, + "end": 40, + "loc": { + "start": { + "line": 1, + "column": 37 + }, + "end": { + "line": 1, + "column": 40 + }, + "identifierName": "bar" + }, + "name": "bar" + } + }, + "extra": { + "shorthand": true + } + } + ] + } + ], + "body": { + "type": "BlockStatement", + "start": 44, + "end": 60, + "loc": { + "start": { + "line": 1, + "column": 44 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 48, + "end": 58, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 12 + } + }, + "expression": { + "type": "AwaitExpression", + "start": 48, + "end": 57, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 11 + } + }, + "argument": { + "type": "Identifier", + "start": 54, + "end": 57, + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 11 + }, + "identifierName": "baz" + }, + "name": "baz" + } + } + } + ], + "directives": [] + } + } + } + ], + "kind": "const" + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/test/fixtures/es2017/async-functions/35/actual.js b/test/fixtures/es2017/async-functions/35/actual.js new file mode 100644 index 0000000000..0071c97792 --- /dev/null +++ b/test/fixtures/es2017/async-functions/35/actual.js @@ -0,0 +1 @@ +const foo = { async = true }; diff --git a/test/fixtures/es2017/async-functions/35/options.json b/test/fixtures/es2017/async-functions/35/options.json new file mode 100644 index 0000000000..0de5e62369 --- /dev/null +++ b/test/fixtures/es2017/async-functions/35/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Unexpected token (1:20)" +} diff --git a/test/fixtures/es2017/async-functions/36/actual.js b/test/fixtures/es2017/async-functions/36/actual.js new file mode 100644 index 0000000000..608bedd985 --- /dev/null +++ b/test/fixtures/es2017/async-functions/36/actual.js @@ -0,0 +1 @@ +const foo = ({ async = true }); diff --git a/test/fixtures/es2017/async-functions/36/options.json b/test/fixtures/es2017/async-functions/36/options.json new file mode 100644 index 0000000000..3e7adc2e54 --- /dev/null +++ b/test/fixtures/es2017/async-functions/36/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Unexpected token (1:21)" +} diff --git a/test/fixtures/es2017/async-functions/37/actual.js b/test/fixtures/es2017/async-functions/37/actual.js new file mode 100644 index 0000000000..0d52a98935 --- /dev/null +++ b/test/fixtures/es2017/async-functions/37/actual.js @@ -0,0 +1 @@ +const { async = true } = foo; diff --git a/test/fixtures/es2017/async-functions/37/expected.json b/test/fixtures/es2017/async-functions/37/expected.json new file mode 100644 index 0000000000..38c3a3e6f3 --- /dev/null +++ b/test/fixtures/es2017/async-functions/37/expected.json @@ -0,0 +1,187 @@ +{ + "type": "File", + "start": 0, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "sourceType": "script", + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 6, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "id": { + "type": "ObjectPattern", + "start": 6, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "properties": [ + { + "type": "ObjectProperty", + "start": 8, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "method": false, + "shorthand": true, + "computed": false, + "key": { + "type": "Identifier", + "start": 8, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 13 + }, + "identifierName": "async" + }, + "name": "async" + }, + "value": { + "type": "AssignmentPattern", + "start": 8, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "left": { + "type": "Identifier", + "start": 8, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 13 + }, + "identifierName": "async" + }, + "name": "async" + }, + "right": { + "type": "BooleanLiteral", + "start": 16, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "value": true + } + }, + "extra": { + "shorthand": true + } + } + ] + }, + "init": { + "type": "Identifier", + "start": 25, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 25 + }, + "end": { + "line": 1, + "column": 28 + }, + "identifierName": "foo" + }, + "name": "foo" + } + } + ], + "kind": "const" + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/test/fixtures/es2017/async-functions/38/actual.js b/test/fixtures/es2017/async-functions/38/actual.js new file mode 100644 index 0000000000..ea101e3323 --- /dev/null +++ b/test/fixtures/es2017/async-functions/38/actual.js @@ -0,0 +1 @@ +const { async: foo } = bar; diff --git a/test/fixtures/es2017/async-functions/38/expected.json b/test/fixtures/es2017/async-functions/38/expected.json new file mode 100644 index 0000000000..8980e6eb41 --- /dev/null +++ b/test/fixtures/es2017/async-functions/38/expected.json @@ -0,0 +1,153 @@ +{ + "type": "File", + "start": 0, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "sourceType": "script", + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 6, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "id": { + "type": "ObjectPattern", + "start": 6, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "properties": [ + { + "type": "ObjectProperty", + "start": 8, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "method": false, + "shorthand": false, + "computed": false, + "key": { + "type": "Identifier", + "start": 8, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 13 + }, + "identifierName": "async" + }, + "name": "async" + }, + "value": { + "type": "Identifier", + "start": 15, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 18 + }, + "identifierName": "foo" + }, + "name": "foo" + } + } + ] + }, + "init": { + "type": "Identifier", + "start": 23, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 23 + }, + "end": { + "line": 1, + "column": 26 + }, + "identifierName": "bar" + }, + "name": "bar" + } + } + ], + "kind": "const" + } + ], + "directives": [] + } +} \ No newline at end of file