"yield" parsing inside function name and parameters (#689)

* Use parseFunctionParams to parse method parameters

* [funct] Set this.state.inGenerator before parsing the function name/params

This allows "yield" inside generator parameters to be actually
parsed as a yield expression

* [funct] Disallow yield in function parameters

* [arrow] "yield" can start an arrow function (e.g. "yield => {}")

* [arrow] Disallow YieldExpressions inside arrow parameters.

* [err msg] Disallow yield as fn name in strict mode using checkReservedWord.

So Babylon throws "yield is a reserved word" instead of
a custom "Binding yield in strict mode"

* [err msg] "X is reserved in strict mode" should have precedence over "X is reserved", since it is more specific.

This was observable if "checkKeywords" is true and the word is both a keyword and a reserved
word in strict mode

* Disallow "yield" as an identifier inside generators

* [tests] Add tests, update wrong esprima tests and enable disabled esprima tests

* [tests] Move uncategorized tests to es2015/yield

* [tests] Update test262 whitelist

* Fix regression introduced by 8c77073

* [tests] Update flow whitelist

* Fix flow errors
This commit is contained in:
Daniel Tschinder
2017-11-01 16:04:22 +01:00
committed by Daniel Tschinder
parent 29a4aea27b
commit 1b612148bf
171 changed files with 3067 additions and 163 deletions

View File

@@ -1 +0,0 @@
yield v

View File

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

View File

@@ -0,0 +1,3 @@
function* fn() {
function yield() {}
}

View File

@@ -0,0 +1,3 @@
{
"throws": "yield is a reserved word inside generator functions (2:11)"
}

View File

@@ -0,0 +1 @@
function yield() {}

View File

@@ -0,0 +1,87 @@
{
"type": "File",
"start": 0,
"end": 19,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 19
}
},
"program": {
"type": "Program",
"start": 0,
"end": 19,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 19
}
},
"sourceType": "script",
"body": [
{
"type": "FunctionDeclaration",
"start": 0,
"end": 19,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 19
}
},
"id": {
"type": "Identifier",
"start": 9,
"end": 14,
"loc": {
"start": {
"line": 1,
"column": 9
},
"end": {
"line": 1,
"column": 14
},
"identifierName": "yield"
},
"name": "yield"
},
"generator": false,
"expression": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 17,
"end": 19,
"loc": {
"start": {
"line": 1,
"column": 17
},
"end": {
"line": 1,
"column": 19
}
},
"body": [],
"directives": []
}
}
],
"directives": []
}
}

View File

@@ -0,0 +1,3 @@
function* fn() {
(function yield() {});
}

View File

@@ -0,0 +1,160 @@
{
"type": "File",
"start": 0,
"end": 43,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 3,
"column": 1
}
},
"program": {
"type": "Program",
"start": 0,
"end": 43,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 3,
"column": 1
}
},
"sourceType": "script",
"body": [
{
"type": "FunctionDeclaration",
"start": 0,
"end": 43,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 3,
"column": 1
}
},
"id": {
"type": "Identifier",
"start": 10,
"end": 12,
"loc": {
"start": {
"line": 1,
"column": 10
},
"end": {
"line": 1,
"column": 12
},
"identifierName": "fn"
},
"name": "fn"
},
"generator": true,
"expression": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 15,
"end": 43,
"loc": {
"start": {
"line": 1,
"column": 15
},
"end": {
"line": 3,
"column": 1
}
},
"body": [
{
"type": "ExpressionStatement",
"start": 19,
"end": 41,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 2,
"column": 24
}
},
"expression": {
"type": "FunctionExpression",
"start": 20,
"end": 39,
"loc": {
"start": {
"line": 2,
"column": 3
},
"end": {
"line": 2,
"column": 22
}
},
"id": {
"type": "Identifier",
"start": 29,
"end": 34,
"loc": {
"start": {
"line": 2,
"column": 12
},
"end": {
"line": 2,
"column": 17
},
"identifierName": "yield"
},
"name": "yield"
},
"generator": false,
"expression": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 37,
"end": 39,
"loc": {
"start": {
"line": 2,
"column": 20
},
"end": {
"line": 2,
"column": 22
}
},
"body": [],
"directives": []
},
"extra": {
"parenthesized": true,
"parenStart": 19
}
}
}
],
"directives": []
}
}
],
"directives": []
}
}

View File

@@ -0,0 +1 @@
+function yield() {}

View File

@@ -0,0 +1,122 @@
{
"type": "File",
"start": 0,
"end": 20,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 20
}
},
"program": {
"type": "Program",
"start": 0,
"end": 20,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 20
}
},
"sourceType": "script",
"body": [
{
"type": "ExpressionStatement",
"start": 0,
"end": 20,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 20
}
},
"expression": {
"type": "UnaryExpression",
"start": 0,
"end": 20,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 20
}
},
"operator": "+",
"prefix": true,
"argument": {
"type": "FunctionExpression",
"start": 1,
"end": 20,
"loc": {
"start": {
"line": 1,
"column": 1
},
"end": {
"line": 1,
"column": 20
}
},
"id": {
"type": "Identifier",
"start": 10,
"end": 15,
"loc": {
"start": {
"line": 1,
"column": 10
},
"end": {
"line": 1,
"column": 15
},
"identifierName": "yield"
},
"name": "yield"
},
"generator": false,
"expression": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 18,
"end": 20,
"loc": {
"start": {
"line": 1,
"column": 18
},
"end": {
"line": 1,
"column": 20
}
},
"body": [],
"directives": []
}
},
"extra": {
"parenthesizedArgument": false
}
}
}
],
"directives": []
}
}

View File

@@ -0,0 +1,3 @@
class A {
yield() {}
}

View File

@@ -0,0 +1,141 @@
{
"type": "File",
"start": 0,
"end": 24,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 3,
"column": 1
}
},
"program": {
"type": "Program",
"start": 0,
"end": 24,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 3,
"column": 1
}
},
"sourceType": "script",
"body": [
{
"type": "ClassDeclaration",
"start": 0,
"end": 24,
"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": "A"
},
"name": "A"
},
"superClass": null,
"body": {
"type": "ClassBody",
"start": 8,
"end": 24,
"loc": {
"start": {
"line": 1,
"column": 8
},
"end": {
"line": 3,
"column": 1
}
},
"body": [
{
"type": "ClassMethod",
"start": 12,
"end": 22,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 2,
"column": 12
}
},
"static": false,
"computed": false,
"key": {
"type": "Identifier",
"start": 12,
"end": 17,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 2,
"column": 7
},
"identifierName": "yield"
},
"name": "yield"
},
"kind": "method",
"id": null,
"generator": false,
"expression": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 20,
"end": 22,
"loc": {
"start": {
"line": 2,
"column": 10
},
"end": {
"line": 2,
"column": 12
}
},
"body": [],
"directives": []
}
}
]
}
}
],
"directives": []
}
}

View File

@@ -0,0 +1 @@
function* yield() {}

View File

@@ -0,0 +1,87 @@
{
"type": "File",
"start": 0,
"end": 20,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 20
}
},
"program": {
"type": "Program",
"start": 0,
"end": 20,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 20
}
},
"sourceType": "script",
"body": [
{
"type": "FunctionDeclaration",
"start": 0,
"end": 20,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 20
}
},
"id": {
"type": "Identifier",
"start": 10,
"end": 15,
"loc": {
"start": {
"line": 1,
"column": 10
},
"end": {
"line": 1,
"column": 15
},
"identifierName": "yield"
},
"name": "yield"
},
"generator": true,
"expression": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 18,
"end": 20,
"loc": {
"start": {
"line": 1,
"column": 18
},
"end": {
"line": 1,
"column": 20
}
},
"body": [],
"directives": []
}
}
],
"directives": []
}
}

View File

@@ -0,0 +1 @@
+function* yield() {}

View File

@@ -0,0 +1,3 @@
{
"throws": "yield is a reserved word inside generator functions (1:11)"
}

View File

@@ -0,0 +1,3 @@
class A {
*yield() {}
}

View File

@@ -0,0 +1,141 @@
{
"type": "File",
"start": 0,
"end": 25,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 3,
"column": 1
}
},
"program": {
"type": "Program",
"start": 0,
"end": 25,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 3,
"column": 1
}
},
"sourceType": "script",
"body": [
{
"type": "ClassDeclaration",
"start": 0,
"end": 25,
"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": "A"
},
"name": "A"
},
"superClass": null,
"body": {
"type": "ClassBody",
"start": 8,
"end": 25,
"loc": {
"start": {
"line": 1,
"column": 8
},
"end": {
"line": 3,
"column": 1
}
},
"body": [
{
"type": "ClassMethod",
"start": 12,
"end": 23,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 2,
"column": 13
}
},
"static": false,
"kind": "method",
"computed": false,
"key": {
"type": "Identifier",
"start": 13,
"end": 18,
"loc": {
"start": {
"line": 2,
"column": 3
},
"end": {
"line": 2,
"column": 8
},
"identifierName": "yield"
},
"name": "yield"
},
"id": null,
"generator": true,
"expression": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 21,
"end": 23,
"loc": {
"start": {
"line": 2,
"column": 11
},
"end": {
"line": 2,
"column": 13
}
},
"body": [],
"directives": []
}
}
]
}
}
],
"directives": []
}
}

View File

@@ -0,0 +1,3 @@
function fn() {
function yield() {}
}

View File

@@ -0,0 +1,141 @@
{
"type": "File",
"start": 0,
"end": 39,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 3,
"column": 1
}
},
"program": {
"type": "Program",
"start": 0,
"end": 39,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 3,
"column": 1
}
},
"sourceType": "script",
"body": [
{
"type": "FunctionDeclaration",
"start": 0,
"end": 39,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 3,
"column": 1
}
},
"id": {
"type": "Identifier",
"start": 9,
"end": 11,
"loc": {
"start": {
"line": 1,
"column": 9
},
"end": {
"line": 1,
"column": 11
},
"identifierName": "fn"
},
"name": "fn"
},
"generator": false,
"expression": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 14,
"end": 39,
"loc": {
"start": {
"line": 1,
"column": 14
},
"end": {
"line": 3,
"column": 1
}
},
"body": [
{
"type": "FunctionDeclaration",
"start": 18,
"end": 37,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 2,
"column": 21
}
},
"id": {
"type": "Identifier",
"start": 27,
"end": 32,
"loc": {
"start": {
"line": 2,
"column": 11
},
"end": {
"line": 2,
"column": 16
},
"identifierName": "yield"
},
"name": "yield"
},
"generator": false,
"expression": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 35,
"end": 37,
"loc": {
"start": {
"line": 2,
"column": 19
},
"end": {
"line": 2,
"column": 21
}
},
"body": [],
"directives": []
}
}
],
"directives": []
}
}
],
"directives": []
}
}

View File

@@ -0,0 +1 @@
function yield() { "use strict"; }

View File

@@ -0,0 +1,3 @@
{
"throws": "yield is a reserved word in strict mode (1:9)"
}

View File

@@ -0,0 +1,2 @@
"use strict";
function yield() {}

View File

@@ -0,0 +1,3 @@
{
"throws": "yield is a reserved word in strict mode (2:9)"
}

View File

@@ -0,0 +1,4 @@
function* fn() {
() => yield;
() => { yield };
}

View File

@@ -0,0 +1,225 @@
{
"type": "File",
"start": 0,
"end": 52,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 4,
"column": 1
}
},
"program": {
"type": "Program",
"start": 0,
"end": 52,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 4,
"column": 1
}
},
"sourceType": "script",
"body": [
{
"type": "FunctionDeclaration",
"start": 0,
"end": 52,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 4,
"column": 1
}
},
"id": {
"type": "Identifier",
"start": 10,
"end": 12,
"loc": {
"start": {
"line": 1,
"column": 10
},
"end": {
"line": 1,
"column": 12
},
"identifierName": "fn"
},
"name": "fn"
},
"generator": true,
"expression": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 15,
"end": 52,
"loc": {
"start": {
"line": 1,
"column": 15
},
"end": {
"line": 4,
"column": 1
}
},
"body": [
{
"type": "ExpressionStatement",
"start": 19,
"end": 31,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 2,
"column": 14
}
},
"expression": {
"type": "ArrowFunctionExpression",
"start": 19,
"end": 30,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 2,
"column": 13
}
},
"id": null,
"generator": false,
"expression": true,
"async": false,
"params": [],
"body": {
"type": "Identifier",
"start": 25,
"end": 30,
"loc": {
"start": {
"line": 2,
"column": 8
},
"end": {
"line": 2,
"column": 13
},
"identifierName": "yield"
},
"name": "yield"
}
}
},
{
"type": "ExpressionStatement",
"start": 34,
"end": 50,
"loc": {
"start": {
"line": 3,
"column": 2
},
"end": {
"line": 3,
"column": 18
}
},
"expression": {
"type": "ArrowFunctionExpression",
"start": 34,
"end": 49,
"loc": {
"start": {
"line": 3,
"column": 2
},
"end": {
"line": 3,
"column": 17
}
},
"id": null,
"generator": false,
"expression": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 40,
"end": 49,
"loc": {
"start": {
"line": 3,
"column": 8
},
"end": {
"line": 3,
"column": 17
}
},
"body": [
{
"type": "ExpressionStatement",
"start": 42,
"end": 47,
"loc": {
"start": {
"line": 3,
"column": 10
},
"end": {
"line": 3,
"column": 15
}
},
"expression": {
"type": "Identifier",
"start": 42,
"end": 47,
"loc": {
"start": {
"line": 3,
"column": 10
},
"end": {
"line": 3,
"column": 15
},
"identifierName": "yield"
},
"name": "yield"
}
}
],
"directives": []
}
}
}
],
"directives": []
}
}
],
"directives": []
}
}

View File

@@ -0,0 +1,3 @@
function* fn() {
() => (x = yield) => {};
}

View File

@@ -0,0 +1,210 @@
{
"type": "File",
"start": 0,
"end": 45,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 3,
"column": 1
}
},
"program": {
"type": "Program",
"start": 0,
"end": 45,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 3,
"column": 1
}
},
"sourceType": "script",
"body": [
{
"type": "FunctionDeclaration",
"start": 0,
"end": 45,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 3,
"column": 1
}
},
"id": {
"type": "Identifier",
"start": 10,
"end": 12,
"loc": {
"start": {
"line": 1,
"column": 10
},
"end": {
"line": 1,
"column": 12
},
"identifierName": "fn"
},
"name": "fn"
},
"generator": true,
"expression": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 15,
"end": 45,
"loc": {
"start": {
"line": 1,
"column": 15
},
"end": {
"line": 3,
"column": 1
}
},
"body": [
{
"type": "ExpressionStatement",
"start": 19,
"end": 43,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 2,
"column": 26
}
},
"expression": {
"type": "ArrowFunctionExpression",
"start": 19,
"end": 42,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 2,
"column": 25
}
},
"id": null,
"generator": false,
"expression": true,
"async": false,
"params": [],
"body": {
"type": "ArrowFunctionExpression",
"start": 25,
"end": 42,
"loc": {
"start": {
"line": 2,
"column": 8
},
"end": {
"line": 2,
"column": 25
}
},
"id": null,
"generator": false,
"expression": false,
"async": false,
"params": [
{
"type": "AssignmentPattern",
"start": 26,
"end": 35,
"loc": {
"start": {
"line": 2,
"column": 9
},
"end": {
"line": 2,
"column": 18
}
},
"left": {
"type": "Identifier",
"start": 26,
"end": 27,
"loc": {
"start": {
"line": 2,
"column": 9
},
"end": {
"line": 2,
"column": 10
},
"identifierName": "x"
},
"name": "x"
},
"right": {
"type": "Identifier",
"start": 30,
"end": 35,
"loc": {
"start": {
"line": 2,
"column": 13
},
"end": {
"line": 2,
"column": 18
},
"identifierName": "yield"
},
"name": "yield"
}
}
],
"body": {
"type": "BlockStatement",
"start": 40,
"end": 42,
"loc": {
"start": {
"line": 2,
"column": 23
},
"end": {
"line": 2,
"column": 25
}
},
"body": [],
"directives": []
}
}
}
}
],
"directives": []
}
}
],
"directives": []
}
}

View File

@@ -0,0 +1,3 @@
function* fn() {
(x = yield) => {};
}

View File

@@ -0,0 +1,3 @@
{
"throws": "yield is not allowed in the parameters of an arrow function inside a generator (2:7)"
}

View File

@@ -0,0 +1,3 @@
function* fn() {
(x = 3 + a.b(yield) ** 2) => {};
}

View File

@@ -0,0 +1,3 @@
{
"throws": "yield is not allowed in the parameters of an arrow function inside a generator (2:15)"
}

View File

@@ -0,0 +1,3 @@
function* fn() {
(x = yield fn) => {};
}

View File

@@ -0,0 +1,3 @@
{
"throws": "yield is not allowed in the parameters of an arrow function inside a generator (2:7)"
}

View File

@@ -0,0 +1,3 @@
function* fn() {
(a, b = 3, x = yield) => {};
}

View File

@@ -0,0 +1,3 @@
{
"throws": "yield is not allowed in the parameters of an arrow function inside a generator (2:17)"
}

View File

@@ -0,0 +1,3 @@
function* fn() {
(x = (yield) => {}) => {};
}

View File

@@ -0,0 +1,3 @@
{
"throws": "yield is not allowed in the parameters of an arrow function inside a generator (2:8)"
}

View File

@@ -0,0 +1 @@
(x = yield) => {}

View File

@@ -0,0 +1,136 @@
{
"type": "File",
"start": 0,
"end": 17,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 17
}
},
"program": {
"type": "Program",
"start": 0,
"end": 17,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 17
}
},
"sourceType": "script",
"body": [
{
"type": "ExpressionStatement",
"start": 0,
"end": 17,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 17
}
},
"expression": {
"type": "ArrowFunctionExpression",
"start": 0,
"end": 17,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 17
}
},
"id": null,
"generator": false,
"expression": false,
"async": false,
"params": [
{
"type": "AssignmentPattern",
"start": 1,
"end": 10,
"loc": {
"start": {
"line": 1,
"column": 1
},
"end": {
"line": 1,
"column": 10
}
},
"left": {
"type": "Identifier",
"start": 1,
"end": 2,
"loc": {
"start": {
"line": 1,
"column": 1
},
"end": {
"line": 1,
"column": 2
},
"identifierName": "x"
},
"name": "x"
},
"right": {
"type": "Identifier",
"start": 5,
"end": 10,
"loc": {
"start": {
"line": 1,
"column": 5
},
"end": {
"line": 1,
"column": 10
},
"identifierName": "yield"
},
"name": "yield"
}
}
],
"body": {
"type": "BlockStatement",
"start": 15,
"end": 17,
"loc": {
"start": {
"line": 1,
"column": 15
},
"end": {
"line": 1,
"column": 17
}
},
"body": [],
"directives": []
}
}
}
],
"directives": []
}
}

View File

@@ -0,0 +1,3 @@
function* fn() {
function fn2(x = yield) {}
}

View File

@@ -0,0 +1,191 @@
{
"type": "File",
"start": 0,
"end": 47,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 3,
"column": 1
}
},
"program": {
"type": "Program",
"start": 0,
"end": 47,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 3,
"column": 1
}
},
"sourceType": "script",
"body": [
{
"type": "FunctionDeclaration",
"start": 0,
"end": 47,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 3,
"column": 1
}
},
"id": {
"type": "Identifier",
"start": 10,
"end": 12,
"loc": {
"start": {
"line": 1,
"column": 10
},
"end": {
"line": 1,
"column": 12
},
"identifierName": "fn"
},
"name": "fn"
},
"generator": true,
"expression": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 15,
"end": 47,
"loc": {
"start": {
"line": 1,
"column": 15
},
"end": {
"line": 3,
"column": 1
}
},
"body": [
{
"type": "FunctionDeclaration",
"start": 19,
"end": 45,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 2,
"column": 28
}
},
"id": {
"type": "Identifier",
"start": 28,
"end": 31,
"loc": {
"start": {
"line": 2,
"column": 11
},
"end": {
"line": 2,
"column": 14
},
"identifierName": "fn2"
},
"name": "fn2"
},
"generator": false,
"expression": false,
"async": false,
"params": [
{
"type": "AssignmentPattern",
"start": 32,
"end": 41,
"loc": {
"start": {
"line": 2,
"column": 15
},
"end": {
"line": 2,
"column": 24
}
},
"left": {
"type": "Identifier",
"start": 32,
"end": 33,
"loc": {
"start": {
"line": 2,
"column": 15
},
"end": {
"line": 2,
"column": 16
},
"identifierName": "x"
},
"name": "x"
},
"right": {
"type": "Identifier",
"start": 36,
"end": 41,
"loc": {
"start": {
"line": 2,
"column": 19
},
"end": {
"line": 2,
"column": 24
},
"identifierName": "yield"
},
"name": "yield"
}
}
],
"body": {
"type": "BlockStatement",
"start": 43,
"end": 45,
"loc": {
"start": {
"line": 2,
"column": 26
},
"end": {
"line": 2,
"column": 28
}
},
"body": [],
"directives": []
}
}
],
"directives": []
}
}
],
"directives": []
}
}

View File

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

View File

@@ -1,7 +1,7 @@
{
"type": "File",
"start": 0,
"end": 24,
"end": 25,
"loc": {
"start": {
"line": 1,
@@ -9,13 +9,13 @@
},
"end": {
"line": 1,
"column": 24
"column": 25
}
},
"program": {
"type": "Program",
"start": 0,
"end": 24,
"end": 25,
"loc": {
"start": {
"line": 1,
@@ -23,7 +23,7 @@
},
"end": {
"line": 1,
"column": 24
"column": 25
}
},
"sourceType": "script",
@@ -31,7 +31,7 @@
{
"type": "FunctionDeclaration",
"start": 0,
"end": 24,
"end": 25,
"loc": {
"start": {
"line": 1,
@@ -39,27 +39,27 @@
},
"end": {
"line": 1,
"column": 24
"column": 25
}
},
"id": {
"type": "Identifier",
"start": 10,
"start": 9,
"end": 11,
"loc": {
"start": {
"line": 1,
"column": 10
"column": 9
},
"end": {
"line": 1,
"column": 11
},
"identifierName": "g"
"identifierName": "fn"
},
"name": "g"
"name": "fn"
},
"generator": true,
"generator": false,
"expression": false,
"async": false,
"params": [
@@ -115,16 +115,16 @@
],
"body": {
"type": "BlockStatement",
"start": 22,
"end": 24,
"start": 23,
"end": 25,
"loc": {
"start": {
"line": 1,
"column": 22
"column": 23
},
"end": {
"line": 1,
"column": 24
"column": 25
}
},
"body": [],

View File

@@ -0,0 +1 @@
({ *method(x = yield) {} })

View File

@@ -0,0 +1,3 @@
{
"throws": "yield is not allowed in generator parameters (1:15)"
}

View File

@@ -0,0 +1 @@
function* fn(x = yield) {}

View File

@@ -0,0 +1,3 @@
{
"throws": "yield is not allowed in generator parameters (1:17)"
}

View File

@@ -0,0 +1,2 @@
"use strict";
function fn(x = yield) {}

View File

@@ -0,0 +1,3 @@
{
"throws": "yield is a reserved word in strict mode (2:16)"
}

View File

@@ -0,0 +1,3 @@
function* fn() {
() => (yield) => {};
}

View File

@@ -0,0 +1,178 @@
{
"type": "File",
"start": 0,
"end": 41,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 3,
"column": 1
}
},
"program": {
"type": "Program",
"start": 0,
"end": 41,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 3,
"column": 1
}
},
"sourceType": "script",
"body": [
{
"type": "FunctionDeclaration",
"start": 0,
"end": 41,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 3,
"column": 1
}
},
"id": {
"type": "Identifier",
"start": 10,
"end": 12,
"loc": {
"start": {
"line": 1,
"column": 10
},
"end": {
"line": 1,
"column": 12
},
"identifierName": "fn"
},
"name": "fn"
},
"generator": true,
"expression": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 15,
"end": 41,
"loc": {
"start": {
"line": 1,
"column": 15
},
"end": {
"line": 3,
"column": 1
}
},
"body": [
{
"type": "ExpressionStatement",
"start": 19,
"end": 39,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 2,
"column": 22
}
},
"expression": {
"type": "ArrowFunctionExpression",
"start": 19,
"end": 38,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 2,
"column": 21
}
},
"id": null,
"generator": false,
"expression": true,
"async": false,
"params": [],
"body": {
"type": "ArrowFunctionExpression",
"start": 25,
"end": 38,
"loc": {
"start": {
"line": 2,
"column": 8
},
"end": {
"line": 2,
"column": 21
}
},
"id": null,
"generator": false,
"expression": false,
"async": false,
"params": [
{
"type": "Identifier",
"start": 26,
"end": 31,
"loc": {
"start": {
"line": 2,
"column": 9
},
"end": {
"line": 2,
"column": 14
},
"identifierName": "yield"
},
"name": "yield"
}
],
"body": {
"type": "BlockStatement",
"start": 36,
"end": 38,
"loc": {
"start": {
"line": 2,
"column": 19
},
"end": {
"line": 2,
"column": 21
}
},
"body": [],
"directives": []
}
}
}
}
],
"directives": []
}
}
],
"directives": []
}
}

View File

@@ -0,0 +1,3 @@
function* fn() {
(yield) => {};
}

View File

@@ -0,0 +1,3 @@
{
"throws": "yield is not allowed in the parameters of an arrow function inside a generator (2:3)"
}

View File

@@ -0,0 +1,3 @@
function* fn() {
(yield fn) => {};
}

View File

@@ -0,0 +1,3 @@
{
"throws": "yield is not allowed in the parameters of an arrow function inside a generator (2:3)"
}

View File

@@ -0,0 +1,3 @@
function* fn() {
(a, b, yield) => {};
}

View File

@@ -0,0 +1,3 @@
{
"throws": "yield is not allowed in the parameters of an arrow function inside a generator (2:9)"
}

View File

@@ -0,0 +1,3 @@
function* fn() {
yield => {};
}

View File

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

View File

@@ -0,0 +1 @@
yield => {};

View File

@@ -0,0 +1,104 @@
{
"type": "File",
"start": 0,
"end": 12,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 12
}
},
"program": {
"type": "Program",
"start": 0,
"end": 12,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 12
}
},
"sourceType": "script",
"body": [
{
"type": "ExpressionStatement",
"start": 0,
"end": 12,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 12
}
},
"expression": {
"type": "ArrowFunctionExpression",
"start": 0,
"end": 11,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 11
}
},
"id": null,
"generator": false,
"expression": false,
"async": false,
"params": [
{
"type": "Identifier",
"start": 0,
"end": 5,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 5
},
"identifierName": "yield"
},
"name": "yield"
}
],
"body": {
"type": "BlockStatement",
"start": 9,
"end": 11,
"loc": {
"start": {
"line": 1,
"column": 9
},
"end": {
"line": 1,
"column": 11
}
},
"body": [],
"directives": []
}
}
}
],
"directives": []
}
}

View File

@@ -0,0 +1 @@
(yield) => {}

View File

@@ -0,0 +1,104 @@
{
"type": "File",
"start": 0,
"end": 13,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 13
}
},
"program": {
"type": "Program",
"start": 0,
"end": 13,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 13
}
},
"sourceType": "script",
"body": [
{
"type": "ExpressionStatement",
"start": 0,
"end": 13,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 13
}
},
"expression": {
"type": "ArrowFunctionExpression",
"start": 0,
"end": 13,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 13
}
},
"id": null,
"generator": false,
"expression": false,
"async": false,
"params": [
{
"type": "Identifier",
"start": 1,
"end": 6,
"loc": {
"start": {
"line": 1,
"column": 1
},
"end": {
"line": 1,
"column": 6
},
"identifierName": "yield"
},
"name": "yield"
}
],
"body": {
"type": "BlockStatement",
"start": 11,
"end": 13,
"loc": {
"start": {
"line": 1,
"column": 11
},
"end": {
"line": 1,
"column": 13
}
},
"body": [],
"directives": []
}
}
}
],
"directives": []
}
}

View File

@@ -0,0 +1 @@
function fn(yield) {}

View File

@@ -0,0 +1,105 @@
{
"type": "File",
"start": 0,
"end": 21,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 21
}
},
"program": {
"type": "Program",
"start": 0,
"end": 21,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 21
}
},
"sourceType": "script",
"body": [
{
"type": "FunctionDeclaration",
"start": 0,
"end": 21,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 21
}
},
"id": {
"type": "Identifier",
"start": 9,
"end": 11,
"loc": {
"start": {
"line": 1,
"column": 9
},
"end": {
"line": 1,
"column": 11
},
"identifierName": "fn"
},
"name": "fn"
},
"generator": false,
"expression": false,
"async": false,
"params": [
{
"type": "Identifier",
"start": 12,
"end": 17,
"loc": {
"start": {
"line": 1,
"column": 12
},
"end": {
"line": 1,
"column": 17
},
"identifierName": "yield"
},
"name": "yield"
}
],
"body": {
"type": "BlockStatement",
"start": 19,
"end": 21,
"loc": {
"start": {
"line": 1,
"column": 19
},
"end": {
"line": 1,
"column": 21
}
},
"body": [],
"directives": []
}
}
],
"directives": []
}
}

View File

@@ -0,0 +1 @@
({ *method(yield) {} });

View File

@@ -0,0 +1,3 @@
{
"throws": "yield is a reserved word inside generator functions (1:11)"
}

View File

@@ -0,0 +1 @@
function* fn(yield) {}

View File

@@ -0,0 +1,3 @@
{
"throws": "yield is a reserved word inside generator functions (1:13)"
}

View File

@@ -0,0 +1 @@
function fn(yield) { "use strict"; }

View File

@@ -0,0 +1,3 @@
{
"throws": "yield is a reserved word in strict mode (1:12)"
}

View File

@@ -0,0 +1,2 @@
"use strict";
function fn(yield) {}

View File

@@ -0,0 +1,3 @@
{
"throws": "yield is a reserved word in strict mode (2:12)"
}

Some files were not shown because too many files have changed in this diff Show More