Make yield a contextual keyword (#9400)

This commit is contained in:
Daniel Tschinder
2019-01-23 14:33:23 -08:00
committed by GitHub
parent 42c5d3fc4b
commit 46ba5940c2
38 changed files with 768 additions and 126 deletions

View File

@@ -1,4 +1,4 @@
{
"sourceType": "module",
"throws": "await is a reserved word (1:0)"
"throws": "Can not use keyword 'await' outside an async function (1:0)"
}

View File

@@ -1,4 +1,4 @@
{
"sourceType": "module",
"throws": "await is a reserved word (1:6)"
"throws": "Can not use keyword 'await' outside an async function (1:6)"
}

View File

@@ -1,4 +1,4 @@
{
"sourceType": "module",
"throws": "await is a reserved word (1:8)"
"throws": "Can not use keyword 'await' outside an async function (1:8)"
}

View File

@@ -1,4 +1,4 @@
{
"sourceType": "module",
"throws": "await is a reserved word (1:15)"
"throws": "Can not use keyword 'await' outside an async function (1:15)"
}

View File

@@ -1,4 +1,4 @@
{
"sourceType": "module",
"throws": "await is a reserved word (1:9)"
"throws": "Can not use keyword 'await' outside an async function (1:9)"
}

View File

@@ -1,4 +1,4 @@
{
"sourceType": "module",
"throws": "await is a reserved word (1:6)"
"throws": "Can not use keyword 'await' outside an async function (1:6)"
}

View File

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

View File

@@ -0,0 +1,194 @@
{
"type": "File",
"start": 0,
"end": 46,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 3,
"column": 1
}
},
"program": {
"type": "Program",
"start": 0,
"end": 46,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 3,
"column": 1
}
},
"sourceType": "script",
"interpreter": null,
"body": [
{
"type": "FunctionDeclaration",
"start": 0,
"end": 46,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 3,
"column": 1
}
},
"id": {
"type": "Identifier",
"start": 10,
"end": 14,
"loc": {
"start": {
"line": 1,
"column": 10
},
"end": {
"line": 1,
"column": 14
},
"identifierName": "wrap"
},
"name": "wrap"
},
"generator": true,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 17,
"end": 46,
"loc": {
"start": {
"line": 1,
"column": 17
},
"end": {
"line": 3,
"column": 1
}
},
"body": [
{
"type": "ClassDeclaration",
"start": 23,
"end": 44,
"loc": {
"start": {
"line": 2,
"column": 4
},
"end": {
"line": 2,
"column": 25
}
},
"id": {
"type": "Identifier",
"start": 29,
"end": 30,
"loc": {
"start": {
"line": 2,
"column": 10
},
"end": {
"line": 2,
"column": 11
},
"identifierName": "A"
},
"name": "A"
},
"superClass": null,
"body": {
"type": "ClassBody",
"start": 31,
"end": 44,
"loc": {
"start": {
"line": 2,
"column": 12
},
"end": {
"line": 2,
"column": 25
}
},
"body": [
{
"type": "ClassMethod",
"start": 32,
"end": 43,
"loc": {
"start": {
"line": 2,
"column": 13
},
"end": {
"line": 2,
"column": 24
}
},
"static": false,
"kind": "method",
"key": {
"type": "Identifier",
"start": 33,
"end": 38,
"loc": {
"start": {
"line": 2,
"column": 14
},
"end": {
"line": 2,
"column": 19
},
"identifierName": "yield"
},
"name": "yield"
},
"computed": false,
"id": null,
"generator": true,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 41,
"end": 43,
"loc": {
"start": {
"line": 2,
"column": 22
},
"end": {
"line": 2,
"column": 24
}
},
"body": [],
"directives": []
}
}
]
}
}
],
"directives": []
}
}
],
"directives": []
}
}

View File

@@ -1,3 +1,3 @@
{
"throws": "yield is a reserved word inside generator functions (2:11)"
"throws": "Can not use 'yield' as identifier inside a generator (2:11)"
}

View File

@@ -1,3 +1,3 @@
{
"throws": "yield is a reserved word inside generator functions (1:11)"
"throws": "Can not use 'yield' as identifier inside a generator (1:11)"
}

View File

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

View File

@@ -0,0 +1,180 @@
{
"type": "File",
"start": 0,
"end": 40,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 3,
"column": 1
}
},
"program": {
"type": "Program",
"start": 0,
"end": 40,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 3,
"column": 1
}
},
"sourceType": "script",
"interpreter": null,
"body": [
{
"type": "FunctionDeclaration",
"start": 0,
"end": 40,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 3,
"column": 1
}
},
"id": {
"type": "Identifier",
"start": 10,
"end": 14,
"loc": {
"start": {
"line": 1,
"column": 10
},
"end": {
"line": 1,
"column": 14
},
"identifierName": "wrap"
},
"name": "wrap"
},
"generator": true,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 17,
"end": 40,
"loc": {
"start": {
"line": 1,
"column": 17
},
"end": {
"line": 3,
"column": 1
}
},
"body": [
{
"type": "ExpressionStatement",
"start": 23,
"end": 38,
"loc": {
"start": {
"line": 2,
"column": 4
},
"end": {
"line": 2,
"column": 19
}
},
"expression": {
"type": "ObjectExpression",
"start": 24,
"end": 37,
"loc": {
"start": {
"line": 2,
"column": 5
},
"end": {
"line": 2,
"column": 18
}
},
"properties": [
{
"type": "ObjectMethod",
"start": 25,
"end": 36,
"loc": {
"start": {
"line": 2,
"column": 6
},
"end": {
"line": 2,
"column": 17
}
},
"method": true,
"key": {
"type": "Identifier",
"start": 26,
"end": 31,
"loc": {
"start": {
"line": 2,
"column": 7
},
"end": {
"line": 2,
"column": 12
},
"identifierName": "yield"
},
"name": "yield"
},
"computed": false,
"kind": "method",
"id": null,
"generator": true,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 34,
"end": 36,
"loc": {
"start": {
"line": 2,
"column": 15
},
"end": {
"line": 2,
"column": 17
}
},
"body": [],
"directives": []
}
}
],
"extra": {
"parenthesized": true,
"parenStart": 23
}
}
}
],
"directives": []
}
}
],
"directives": []
}
}

View File

@@ -0,0 +1 @@
function *f2() { () => yield / 1 }

View File

@@ -0,0 +1,175 @@
{
"type": "File",
"start": 0,
"end": 34,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 34
}
},
"program": {
"type": "Program",
"start": 0,
"end": 34,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 34
}
},
"sourceType": "script",
"interpreter": null,
"body": [
{
"type": "FunctionDeclaration",
"start": 0,
"end": 34,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 34
}
},
"id": {
"type": "Identifier",
"start": 10,
"end": 12,
"loc": {
"start": {
"line": 1,
"column": 10
},
"end": {
"line": 1,
"column": 12
},
"identifierName": "f2"
},
"name": "f2"
},
"generator": true,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 15,
"end": 34,
"loc": {
"start": {
"line": 1,
"column": 15
},
"end": {
"line": 1,
"column": 34
}
},
"body": [
{
"type": "ExpressionStatement",
"start": 17,
"end": 32,
"loc": {
"start": {
"line": 1,
"column": 17
},
"end": {
"line": 1,
"column": 32
}
},
"expression": {
"type": "ArrowFunctionExpression",
"start": 17,
"end": 32,
"loc": {
"start": {
"line": 1,
"column": 17
},
"end": {
"line": 1,
"column": 32
}
},
"id": null,
"generator": false,
"async": false,
"params": [],
"body": {
"type": "BinaryExpression",
"start": 23,
"end": 32,
"loc": {
"start": {
"line": 1,
"column": 23
},
"end": {
"line": 1,
"column": 32
}
},
"left": {
"type": "Identifier",
"start": 23,
"end": 28,
"loc": {
"start": {
"line": 1,
"column": 23
},
"end": {
"line": 1,
"column": 28
},
"identifierName": "yield"
},
"name": "yield"
},
"operator": "/",
"right": {
"type": "NumericLiteral",
"start": 31,
"end": 32,
"loc": {
"start": {
"line": 1,
"column": 31
},
"end": {
"line": 1,
"column": 32
}
},
"extra": {
"rawValue": 1,
"raw": "1"
},
"value": 1
}
}
}
}
],
"directives": []
}
}
],
"directives": []
}
}

View File

@@ -1,3 +1,3 @@
{
"throws": "yield is a reserved word inside generator functions (1:11)"
"throws": "Can not use 'yield' as identifier inside a generator (1:11)"
}

View File

@@ -1,3 +1,3 @@
{
"throws": "yield is a reserved word inside generator functions (1:13)"
"throws": "Can not use 'yield' as identifier inside a generator (1:13)"
}

View File

@@ -0,0 +1 @@
var yield = 2

View File

@@ -0,0 +1,105 @@
{
"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",
"interpreter": null,
"body": [
{
"type": "VariableDeclaration",
"start": 0,
"end": 13,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 13
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 4,
"end": 13,
"loc": {
"start": {
"line": 1,
"column": 4
},
"end": {
"line": 1,
"column": 13
}
},
"id": {
"type": "Identifier",
"start": 4,
"end": 9,
"loc": {
"start": {
"line": 1,
"column": 4
},
"end": {
"line": 1,
"column": 9
},
"identifierName": "yield"
},
"name": "yield"
},
"init": {
"type": "NumericLiteral",
"start": 12,
"end": 13,
"loc": {
"start": {
"line": 1,
"column": 12
},
"end": {
"line": 1,
"column": 13
}
},
"extra": {
"rawValue": 2,
"raw": "2"
},
"value": 2
}
}
],
"kind": "var"
}
],
"directives": []
}
}

View File

@@ -1,3 +1,3 @@
{
"throws": "invalid use of await inside of an async function (1:16)"
"throws": "Can not use 'await' as identifier inside an async function (1:16)"
}

View File

@@ -1,3 +1,3 @@
{
"throws": "invalid use of await inside of an async function (2:11)"
"throws": "Can not use 'await' as identifier inside an async function (2:11)"
}

View File

@@ -1,3 +1,3 @@
{
"throws": "yield is a reserved word inside generator functions (1:30)"
"throws": "Can not use 'yield' as identifier inside a generator (1:30)"
}

View File

@@ -1,3 +1,3 @@
{
"throws": "yield is a reserved word inside generator functions (1:26)"
"throws": "Can not use 'yield' as identifier inside a generator (1:26)"
}

View File

@@ -1,3 +1,4 @@
{
"throws": "'import' and 'export' may appear only with 'sourceType: \"module\"' (1:0)"
"sourceType": "module",
"throws": "yield is a reserved word in strict mode (1:25)"
}

View File

@@ -1,3 +1,3 @@
{
"throws": "yield is a reserved word inside generator functions (1:10)"
"throws": "Can not use 'yield' as identifier inside a generator (1:10)"
}

View File

@@ -1,3 +1,3 @@
{
"throws": "yield is a reserved word inside generator functions (1:12)"
"throws": "Can not use 'yield' as identifier inside a generator (1:12)"
}

View File

@@ -1,3 +1,3 @@
{
"throws": "yield is a reserved word inside generator functions (1:18)"
"throws": "Can not use 'yield' as identifier inside a generator (1:18)"
}

View File

@@ -1,3 +1,3 @@
{
"throws": "yield is a reserved word inside generator functions (1:25)"
"throws": "Can not use 'yield' as identifier inside a generator (1:25)"
}

View File

@@ -1,3 +1,3 @@
{
"throws": "yield is a reserved word inside generator functions (1:20)"
"throws": "Can not use 'yield' as identifier inside a generator (1:20)"
}

View File

@@ -1,3 +1,3 @@
{
"throws": "yield is a reserved word inside generator functions (1:12)"
"throws": "Can not use 'yield' as identifier inside a generator (1:12)"
}

View File

@@ -1,3 +1,3 @@
{
"throws": "yield is a reserved word inside generator functions (1:24)"
"throws": "Can not use 'yield' as identifier inside a generator (1:24)"
}

View File

@@ -1,3 +1,3 @@
{
"throws": "yield is a reserved word inside generator functions (1:20)"
"throws": "Can not use 'yield' as identifier inside a generator (1:20)"
}