Refactor parsing object members (#9607)

* Refactor parsing object members

* Ensure decorators on rest don’t swallow decorators silently

* Use hasPrecedingLineBreak

* Add test for async with linebreak

* Update flow whitelist
This commit is contained in:
Daniel Tschinder
2019-02-28 11:42:12 -08:00
committed by GitHub
parent 208195f425
commit 98ab1b6428
51 changed files with 1060 additions and 179 deletions

View File

@@ -1,3 +1,3 @@
{
"throws": "The rest parameter must be the last parameter (1:18)"
"throws": "Rest element must be last element (1:18)"
}

View File

@@ -1,3 +1,3 @@
{
"throws": "The rest parameter must be the last parameter (3:13)"
"throws": "Rest element must be last element (3:13)"
}

View File

@@ -1,3 +1,3 @@
{
"throws": "A trailing comma is not permitted after the rest element (1:5)"
"throws": "Rest element must be last element (1:5)"
}

View File

@@ -1,3 +1,3 @@
{
"throws": "The rest element must be the last element (1:1)"
"throws": "Rest element must be last element (1:1)"
}

View File

@@ -1,3 +1,3 @@
{
"throws": "A trailing comma is not permitted after the rest parameter (1:8)"
"throws": "Rest element must be last element (1:8)"
}

View File

@@ -1,3 +1,3 @@
{
"throws": "The rest parameter must be the last parameter (3:13)"
"throws": "Rest element must be last element (3:13)"
}

View File

@@ -0,0 +1,4 @@
({
async
foo() {}
})

View File

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

View File

@@ -1,3 +1,3 @@
{
"throws": "The rest parameter must be the last parameter (1:18)"
"throws": "Rest element must be last element (1:18)"
}

View File

@@ -1,3 +1,3 @@
{
"throws": "The rest parameter must be the last parameter (1:5)"
"throws": "Rest element must be last element (1:5)"
}

View File

@@ -1 +0,0 @@
({ __proto__, __proto__: 2 })

View File

@@ -1,3 +0,0 @@
{
"throws": "Redefinition of __proto__ property (1:14)"
}

View File

@@ -1,3 +1,3 @@
{
"throws": "A trailing comma is not permitted after the rest parameter (1:11)"
"throws": "Rest element must be last element (1:11)"
}

View File

@@ -1,3 +1,3 @@
{
"throws": "Invalid rest operator's argument (1:8)"
"throws": "Unexpected token (1:8)"
}

View File

@@ -1,3 +1,3 @@
{
"throws": "Invalid rest operator's argument (1:9)"
"throws": "Unexpected token (1:9)"
}

View File

@@ -1,3 +1,3 @@
{
"throws": "Invalid rest operator's argument (1:18)"
"throws": "Unexpected token (1:18)"
}

View File

@@ -1,3 +1,3 @@
{
"throws": "Invalid rest operator's argument (1:18)"
"throws": "Unexpected token (1:18)"
}

View File

@@ -1,3 +1,3 @@
{
"throws": "Invalid rest operator's argument (1:8)"
"throws": "Unexpected token, expected \",\" (1:10)"
}

View File

@@ -1,3 +1,3 @@
{
"throws": "Invalid rest operator's argument (1:18)"
"throws": "Unexpected token, expected \",\" (1:20)"
}

View File

@@ -1,3 +1,3 @@
{
"throws": "Invalid rest operator's argument (1:8)"
"throws": "Unexpected token (1:8)"
}

View File

@@ -1,3 +1,3 @@
{
"throws": "Invalid rest operator's argument (1:18)"
"throws": "Unexpected token (1:18)"
}

View File

@@ -1,3 +1,3 @@
{
"throws": "The rest property must be the last property (1:10)"
"throws": "Rest element must be last element (1:10)"
}

View File

@@ -1,3 +1,3 @@
{
"throws": "A trailing comma is not permitted after the rest property (1:16)"
"throws": "Rest element must be last element (1:16)"
}

View File

@@ -1,3 +1,3 @@
{
"throws": "The rest property must be the last property (1:13)"
"throws": "Rest element must be last element (1:13)"
}

View File

@@ -1,3 +1,3 @@
{
"throws": "A trailing comma is not permitted after the rest property (1:6)"
"throws": "Rest element must be last element (1:6)"
}

View File

@@ -1,3 +1,3 @@
{
"throws": "The rest property must be the last property (1:2)"
"throws": "Rest element must be last element (1:2)"
}

View File

@@ -1,3 +1,3 @@
{
"throws": "The rest parameter must be the last parameter (1:5)"
"throws": "Rest element must be last element (1:5)"
}

View File

@@ -1,3 +0,0 @@
{
"throws": "Redefinition of __proto__ property (1:20)"
}

View File

@@ -1,3 +0,0 @@
{
"throws": "Redefinition of __proto__ property (1:22)"
}

View File

@@ -1,3 +0,0 @@
{
"throws": "Redefinition of __proto__ property (1:14)"
}

View File

@@ -1,3 +0,0 @@
{
"throws": "Redefinition of __proto__ property (1:14)"
}

View File

@@ -1,3 +0,0 @@
{
"throws": "Redefinition of __proto__ property (1:14)"
}

View File

@@ -0,0 +1,176 @@
{
"type": "File",
"start": 0,
"end": 32,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 32
}
},
"program": {
"type": "Program",
"start": 0,
"end": 32,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 32
}
},
"sourceType": "script",
"interpreter": null,
"body": [
{
"type": "ExpressionStatement",
"start": 0,
"end": 32,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 32
}
},
"expression": {
"type": "ObjectExpression",
"start": 1,
"end": 31,
"loc": {
"start": {
"line": 1,
"column": 1
},
"end": {
"line": 1,
"column": 31
}
},
"properties": [
{
"type": "ObjectProperty",
"start": 3,
"end": 18,
"loc": {
"start": {
"line": 1,
"column": 3
},
"end": {
"line": 1,
"column": 18
}
},
"method": false,
"key": {
"type": "Identifier",
"start": 3,
"end": 12,
"loc": {
"start": {
"line": 1,
"column": 3
},
"end": {
"line": 1,
"column": 12
},
"identifierName": "__proto__"
},
"name": "__proto__"
},
"computed": false,
"shorthand": false,
"value": {
"type": "NullLiteral",
"start": 14,
"end": 18,
"loc": {
"start": {
"line": 1,
"column": 14
},
"end": {
"line": 1,
"column": 18
}
}
}
},
{
"type": "ObjectProperty",
"start": 20,
"end": 29,
"loc": {
"start": {
"line": 1,
"column": 20
},
"end": {
"line": 1,
"column": 29
}
},
"method": false,
"key": {
"type": "Identifier",
"start": 20,
"end": 29,
"loc": {
"start": {
"line": 1,
"column": 20
},
"end": {
"line": 1,
"column": 29
},
"identifierName": "__proto__"
},
"name": "__proto__"
},
"computed": false,
"shorthand": true,
"value": {
"type": "Identifier",
"start": 20,
"end": 29,
"loc": {
"start": {
"line": 1,
"column": 20
},
"end": {
"line": 1,
"column": 29
},
"identifierName": "__proto__"
},
"name": "__proto__"
},
"extra": {
"shorthand": true
}
}
],
"extra": {
"parenthesized": true,
"parenStart": 0
}
}
}
],
"directives": []
}
}

View File

@@ -0,0 +1,179 @@
{
"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": "ExpressionStatement",
"start": 0,
"end": 34,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 34
}
},
"expression": {
"type": "ObjectExpression",
"start": 1,
"end": 33,
"loc": {
"start": {
"line": 1,
"column": 1
},
"end": {
"line": 1,
"column": 33
}
},
"properties": [
{
"type": "ObjectProperty",
"start": 3,
"end": 20,
"loc": {
"start": {
"line": 1,
"column": 3
},
"end": {
"line": 1,
"column": 20
}
},
"method": false,
"key": {
"type": "StringLiteral",
"start": 3,
"end": 14,
"loc": {
"start": {
"line": 1,
"column": 3
},
"end": {
"line": 1,
"column": 14
}
},
"extra": {
"rawValue": "__proto__",
"raw": "\"__proto__\""
},
"value": "__proto__"
},
"computed": false,
"shorthand": false,
"value": {
"type": "NullLiteral",
"start": 16,
"end": 20,
"loc": {
"start": {
"line": 1,
"column": 16
},
"end": {
"line": 1,
"column": 20
}
}
}
},
{
"type": "ObjectProperty",
"start": 22,
"end": 31,
"loc": {
"start": {
"line": 1,
"column": 22
},
"end": {
"line": 1,
"column": 31
}
},
"method": false,
"key": {
"type": "Identifier",
"start": 22,
"end": 31,
"loc": {
"start": {
"line": 1,
"column": 22
},
"end": {
"line": 1,
"column": 31
},
"identifierName": "__proto__"
},
"name": "__proto__"
},
"computed": false,
"shorthand": true,
"value": {
"type": "Identifier",
"start": 22,
"end": 31,
"loc": {
"start": {
"line": 1,
"column": 22
},
"end": {
"line": 1,
"column": 31
},
"identifierName": "__proto__"
},
"name": "__proto__"
},
"extra": {
"shorthand": true
}
}
],
"extra": {
"parenthesized": true,
"parenStart": 0
}
}
}
],
"directives": []
}
}

View File

@@ -0,0 +1,176 @@
{
"type": "File",
"start": 0,
"end": 32,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 32
}
},
"program": {
"type": "Program",
"start": 0,
"end": 32,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 32
}
},
"sourceType": "script",
"interpreter": null,
"body": [
{
"type": "ExpressionStatement",
"start": 0,
"end": 32,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 32
}
},
"expression": {
"type": "ObjectExpression",
"start": 1,
"end": 31,
"loc": {
"start": {
"line": 1,
"column": 1
},
"end": {
"line": 1,
"column": 31
}
},
"properties": [
{
"type": "ObjectProperty",
"start": 3,
"end": 12,
"loc": {
"start": {
"line": 1,
"column": 3
},
"end": {
"line": 1,
"column": 12
}
},
"method": false,
"key": {
"type": "Identifier",
"start": 3,
"end": 12,
"loc": {
"start": {
"line": 1,
"column": 3
},
"end": {
"line": 1,
"column": 12
},
"identifierName": "__proto__"
},
"name": "__proto__"
},
"computed": false,
"shorthand": true,
"value": {
"type": "Identifier",
"start": 3,
"end": 12,
"loc": {
"start": {
"line": 1,
"column": 3
},
"end": {
"line": 1,
"column": 12
},
"identifierName": "__proto__"
},
"name": "__proto__"
},
"extra": {
"shorthand": true
}
},
{
"type": "ObjectProperty",
"start": 14,
"end": 29,
"loc": {
"start": {
"line": 1,
"column": 14
},
"end": {
"line": 1,
"column": 29
}
},
"method": false,
"key": {
"type": "Identifier",
"start": 14,
"end": 23,
"loc": {
"start": {
"line": 1,
"column": 14
},
"end": {
"line": 1,
"column": 23
},
"identifierName": "__proto__"
},
"name": "__proto__"
},
"computed": false,
"shorthand": false,
"value": {
"type": "NullLiteral",
"start": 25,
"end": 29,
"loc": {
"start": {
"line": 1,
"column": 25
},
"end": {
"line": 1,
"column": 29
}
}
}
}
],
"extra": {
"parenthesized": true,
"parenStart": 0
}
}
}
],
"directives": []
}
}

View File

@@ -0,0 +1,179 @@
{
"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": "ExpressionStatement",
"start": 0,
"end": 34,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 34
}
},
"expression": {
"type": "ObjectExpression",
"start": 1,
"end": 33,
"loc": {
"start": {
"line": 1,
"column": 1
},
"end": {
"line": 1,
"column": 33
}
},
"properties": [
{
"type": "ObjectProperty",
"start": 3,
"end": 12,
"loc": {
"start": {
"line": 1,
"column": 3
},
"end": {
"line": 1,
"column": 12
}
},
"method": false,
"key": {
"type": "Identifier",
"start": 3,
"end": 12,
"loc": {
"start": {
"line": 1,
"column": 3
},
"end": {
"line": 1,
"column": 12
},
"identifierName": "__proto__"
},
"name": "__proto__"
},
"computed": false,
"shorthand": true,
"value": {
"type": "Identifier",
"start": 3,
"end": 12,
"loc": {
"start": {
"line": 1,
"column": 3
},
"end": {
"line": 1,
"column": 12
},
"identifierName": "__proto__"
},
"name": "__proto__"
},
"extra": {
"shorthand": true
}
},
{
"type": "ObjectProperty",
"start": 14,
"end": 31,
"loc": {
"start": {
"line": 1,
"column": 14
},
"end": {
"line": 1,
"column": 31
}
},
"method": false,
"key": {
"type": "StringLiteral",
"start": 14,
"end": 25,
"loc": {
"start": {
"line": 1,
"column": 14
},
"end": {
"line": 1,
"column": 25
}
},
"extra": {
"rawValue": "__proto__",
"raw": "\"__proto__\""
},
"value": "__proto__"
},
"computed": false,
"shorthand": false,
"value": {
"type": "NullLiteral",
"start": 27,
"end": 31,
"loc": {
"start": {
"line": 1,
"column": 27
},
"end": {
"line": 1,
"column": 31
}
}
}
}
],
"extra": {
"parenthesized": true,
"parenStart": 0
}
}
}
],
"directives": []
}
}

View File

@@ -0,0 +1,181 @@
{
"type": "File",
"start": 0,
"end": 26,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 26
}
},
"program": {
"type": "Program",
"start": 0,
"end": 26,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 26
}
},
"sourceType": "script",
"interpreter": null,
"body": [
{
"type": "ExpressionStatement",
"start": 0,
"end": 26,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 26
}
},
"expression": {
"type": "ObjectExpression",
"start": 1,
"end": 25,
"loc": {
"start": {
"line": 1,
"column": 1
},
"end": {
"line": 1,
"column": 25
}
},
"properties": [
{
"type": "ObjectProperty",
"start": 3,
"end": 12,
"loc": {
"start": {
"line": 1,
"column": 3
},
"end": {
"line": 1,
"column": 12
}
},
"method": false,
"key": {
"type": "Identifier",
"start": 3,
"end": 12,
"loc": {
"start": {
"line": 1,
"column": 3
},
"end": {
"line": 1,
"column": 12
},
"identifierName": "__proto__"
},
"name": "__proto__"
},
"computed": false,
"shorthand": true,
"value": {
"type": "Identifier",
"start": 3,
"end": 12,
"loc": {
"start": {
"line": 1,
"column": 3
},
"end": {
"line": 1,
"column": 12
},
"identifierName": "__proto__"
},
"name": "__proto__"
},
"extra": {
"shorthand": true
}
},
{
"type": "ObjectProperty",
"start": 14,
"end": 23,
"loc": {
"start": {
"line": 1,
"column": 14
},
"end": {
"line": 1,
"column": 23
}
},
"method": false,
"key": {
"type": "Identifier",
"start": 14,
"end": 23,
"loc": {
"start": {
"line": 1,
"column": 14
},
"end": {
"line": 1,
"column": 23
},
"identifierName": "__proto__"
},
"name": "__proto__"
},
"computed": false,
"shorthand": true,
"value": {
"type": "Identifier",
"start": 14,
"end": 23,
"loc": {
"start": {
"line": 1,
"column": 14
},
"end": {
"line": 1,
"column": 23
},
"identifierName": "__proto__"
},
"name": "__proto__"
},
"extra": {
"shorthand": true
}
}
],
"extra": {
"parenthesized": true,
"parenStart": 0
}
}
}
],
"directives": []
}
}

View File

@@ -1,3 +1,3 @@
{
"throws": "The rest parameter must be the last parameter (1:18)"
"throws": "Rest element must be last element (1:18)"
}

View File

@@ -1,5 +1,5 @@
{
"sourceType": "module",
"plugins": ["typescript"],
"throws": "The rest type must be the last type (1:19)"
"throws": "Rest element must be last element (1:19)"
}