Skip to content

Commit

Permalink
Disallow await inside arrow functions (#9074)
Browse files Browse the repository at this point in the history
* Disallow await inside arrow functions

* Update test262 whitelist
  • Loading branch information
nicolo-ribaudo committed Nov 26, 2018
1 parent 9308c87 commit 61f2aed
Show file tree
Hide file tree
Showing 7 changed files with 128 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/babel-parser/src/parser/expression.js
Expand Up @@ -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);
Expand Down
@@ -0,0 +1 @@
() => { await x }
@@ -0,0 +1,3 @@
{
"throws": "Unexpected token, expected \";\" (1:14)"
}
@@ -0,0 +1 @@
() => { await }
@@ -0,0 +1,3 @@
{
"sourceType": "script"
}
@@ -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": []
}
}
2 changes: 0 additions & 2 deletions scripts/tests/test262/test262_whitelist.txt
Expand Up @@ -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)
Expand Down

0 comments on commit 61f2aed

Please sign in to comment.