Disallow await inside arrow functions (#9074)

* Disallow await inside arrow functions

* Update test262 whitelist
This commit is contained in:
Nicolò Ribaudo 2018-11-26 12:43:04 +01:00 committed by GitHub
parent 9308c870f5
commit 61f2aed5b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 128 additions and 3 deletions

View File

@ -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);

View File

@ -0,0 +1,3 @@
{
"throws": "Unexpected token, expected \";\" (1:14)"
}

View File

@ -0,0 +1,3 @@
{
"sourceType": "script"
}

View File

@ -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": []
}
}

View File

@ -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)