diff --git a/packages/babel-parser/src/parser/expression.js b/packages/babel-parser/src/parser/expression.js index 890d01d6e2..7de715c6fc 100644 --- a/packages/babel-parser/src/parser/expression.js +++ b/packages/babel-parser/src/parser/expression.js @@ -1716,7 +1716,7 @@ export default class ExpressionParser extends LValParser { const oldInAsync = this.state.inAsync; const oldInGenerator = this.state.inGenerator; const oldMaybeInArrowParameters = this.state.maybeInArrowParameters; - this.state.inAsync = true; + this.state.inAsync = isAsync; this.state.inGenerator = false; this.state.maybeInArrowParameters = false; this.parseFunctionBody(node, true); diff --git a/packages/babel-parser/test/fixtures/es2017/async-functions/await-inside-arrow-expression-disallowed/input.js b/packages/babel-parser/test/fixtures/es2017/async-functions/await-inside-arrow-expression-disallowed/input.js new file mode 100644 index 0000000000..5f0476d831 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2017/async-functions/await-inside-arrow-expression-disallowed/input.js @@ -0,0 +1 @@ +() => { await x } \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2017/async-functions/await-inside-arrow-expression-disallowed/options.json b/packages/babel-parser/test/fixtures/es2017/async-functions/await-inside-arrow-expression-disallowed/options.json new file mode 100644 index 0000000000..c83e2245d0 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2017/async-functions/await-inside-arrow-expression-disallowed/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Unexpected token, expected \";\" (1:14)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2017/async-functions/await-inside-arrow-identifier-allowed/input.js b/packages/babel-parser/test/fixtures/es2017/async-functions/await-inside-arrow-identifier-allowed/input.js new file mode 100644 index 0000000000..cbc9d51ace --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2017/async-functions/await-inside-arrow-identifier-allowed/input.js @@ -0,0 +1 @@ +() => { await } \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2017/async-functions/await-inside-arrow-identifier-allowed/options.json b/packages/babel-parser/test/fixtures/es2017/async-functions/await-inside-arrow-identifier-allowed/options.json new file mode 100644 index 0000000000..53135cabff --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2017/async-functions/await-inside-arrow-identifier-allowed/options.json @@ -0,0 +1,3 @@ +{ + "sourceType": "script" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2017/async-functions/await-inside-arrow-identifier-allowed/output.json b/packages/babel-parser/test/fixtures/es2017/async-functions/await-inside-arrow-identifier-allowed/output.json new file mode 100644 index 0000000000..f6ca7cfa0d --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2017/async-functions/await-inside-arrow-identifier-allowed/output.json @@ -0,0 +1,119 @@ +{ + "type": "File", + "start": 0, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "expression": { + "type": "ArrowFunctionExpression", + "start": 0, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "id": null, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 6, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 8, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "expression": { + "type": "Identifier", + "start": 8, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 13 + }, + "identifierName": "await" + }, + "name": "await" + } + } + ], + "directives": [] + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/scripts/tests/test262/test262_whitelist.txt b/scripts/tests/test262/test262_whitelist.txt index b820c4c3a3..c1601fbfc8 100644 --- a/scripts/tests/test262/test262_whitelist.txt +++ b/scripts/tests/test262/test262_whitelist.txt @@ -1654,8 +1654,6 @@ language/statements/switch/syntax/redeclaration/let-declaration-attempt-to-redec language/statements/switch/syntax/redeclaration/let-declaration-attempt-to-redeclare-with-async-generator-declaration.js(strict mode) language/statements/switch/syntax/redeclaration/var-declaration-attempt-to-redeclare-with-async-generator-declaration.js(default) language/statements/switch/syntax/redeclaration/var-declaration-attempt-to-redeclare-with-async-generator-declaration.js(strict mode) -language/expressions/dynamic-import/assignment-expression/await-identifier.js(default) -language/expressions/dynamic-import/assignment-expression/await-identifier.js(strict mode) language/literals/regexp/named-groups/invalid-dangling-groupname-2-u.js(default) language/literals/regexp/named-groups/invalid-dangling-groupname-2-u.js(strict mode) language/literals/regexp/named-groups/invalid-dangling-groupname-2.js(default)