Trailing comma after rest - The final fix (#10491)

* [parser] Track trailing commas in extras instead of state

* Update existing tests

* Update test262 whitelist

* Improve error message and location

* nit

* Use lookaheadCharCode
This commit is contained in:
Nicolò Ribaudo
2019-10-08 23:08:50 +02:00
committed by GitHub
parent c7add11fdc
commit 34937f13d5
46 changed files with 226 additions and 100 deletions

View File

@@ -373,7 +373,10 @@
}
]
}
]
],
"extra": {
"trailingComma": 140
}
}
}
],
@@ -494,7 +497,10 @@
}
]
}
]
],
"extra": {
"trailingComma": 200
}
}
}
],

View File

@@ -74,6 +74,9 @@
},
"name": "fn"
},
"extra": {
"trailingComma": 11
},
"arguments": [
{
"type": "Identifier",

View File

@@ -74,6 +74,9 @@
},
"name": "fn"
},
"extra": {
"trailingComma": 7
},
"arguments": [
{
"type": "Identifier",

View File

@@ -181,6 +181,9 @@
}
}
],
"extra": {
"trailingComma": 35
},
"trailingComments": [
{
"type": "CommentBlock",

View File

@@ -309,7 +309,10 @@
}
]
}
]
],
"extra": {
"trailingComma": 66
}
}
}
],

View File

@@ -163,7 +163,10 @@
}
]
}
]
],
"extra": {
"trailingComma": 13
}
}
},
"trailingComments": [

View File

@@ -110,7 +110,10 @@
},
"value": 42
}
]
],
"extra": {
"trailingComma": 8
}
}
}
}

View File

@@ -150,7 +150,10 @@
},
"value": 3
}
]
],
"extra": {
"trailingComma": 13
}
}
}
}

View File

@@ -151,7 +151,10 @@
},
"value": 3
}
]
],
"extra": {
"trailingComma": 14
}
}
}
}

View File

@@ -1,3 +1,3 @@
{
"throws": "Rest element must be last element (1:5)"
"throws": "Unexpected trailing comma after rest element (1:5)"
}

View File

@@ -0,0 +1 @@
for ([...a,] in []);

View File

@@ -0,0 +1,3 @@
{
"throws": "Unexpected trailing comma after rest element (1:10)"
}

View File

@@ -0,0 +1 @@
[[...a,]] = [];

View File

@@ -0,0 +1,3 @@
{
"throws": "Unexpected trailing comma after rest element (1:6)"
}

View File

@@ -90,7 +90,10 @@
"name": "a"
}
}
]
],
"extra": {
"trailingComma": 5
}
}
}
],

View File

@@ -1,3 +1,3 @@
{
"throws": "Rest element must be last element (1:8)"
"throws": "Unexpected trailing comma after rest element (1:8)"
}

View File

@@ -91,7 +91,10 @@
"name": "x"
},
null
]
],
"extra": {
"trailingComma": 3
}
},
"right": {
"type": "NumericLiteral",

View File

@@ -1,3 +1,3 @@
{
"throws": "Rest element must be last element (1:11)"
}
"throws": "Unexpected trailing comma after rest element (1:11)"
}

View File

@@ -74,6 +74,9 @@
},
"name": "log"
},
"extra": {
"trailingComma": 13
},
"arguments": [
{
"type": "Identifier",

View File

@@ -183,7 +183,10 @@
"shorthand": true
}
}
]
],
"extra": {
"trailingComma": 10
}
},
"init": {
"type": "Identifier",

View File

@@ -289,6 +289,7 @@
}
],
"extra": {
"trailingComma": 21,
"parenthesized": true,
"parenStart": 0
}

View File

@@ -1,3 +1,3 @@
{
"throws": "Rest element must be last element (1:16)"
"throws": "Unexpected trailing comma after rest element (1:16)"
}

View File

@@ -0,0 +1 @@
for ({...a,} in []);

View File

@@ -0,0 +1,3 @@
{
"throws": "Rest element must be last element (1:10)"
}

View File

@@ -0,0 +1 @@
[{...a,}] = [];

View File

@@ -0,0 +1,3 @@
{
"throws": "Rest element must be last element (1:6)"
}

View File

@@ -92,6 +92,7 @@
}
],
"extra": {
"trailingComma": 6,
"parenthesized": true,
"parenStart": 0
}

View File

@@ -78,7 +78,10 @@
"elements": [
null,
null
]
],
"extra": {
"trailingComma": 3
}
}
],
"body": {

View File

@@ -75,7 +75,10 @@
"elements": [
null,
null
]
],
"extra": {
"trailingComma": 2
}
},
"right": {
"type": "NumericLiteral",

View File

@@ -166,6 +166,7 @@
}
],
"extra": {
"trailingComma": 33,
"parenthesized": true,
"parenStart": 0
}

View File

@@ -169,6 +169,7 @@
}
],
"extra": {
"trailingComma": 35,
"parenthesized": true,
"parenStart": 0
}

View File

@@ -128,7 +128,10 @@
"shorthand": true
}
}
]
],
"extra": {
"trailingComma": 6
}
},
"init": {
"type": "NumericLiteral",

View File

@@ -110,7 +110,10 @@
},
"value": 42
}
]
],
"extra": {
"trailingComma": 8
}
}
}
}

View File

@@ -150,7 +150,10 @@
},
"value": 3
}
]
],
"extra": {
"trailingComma": 13
}
}
}
}

View File

@@ -151,7 +151,10 @@
},
"value": 3
}
]
],
"extra": {
"trailingComma": 14
}
}
}
}

View File

@@ -1,3 +1,3 @@
{
"throws": "Trailing comma is disallowed inside import(...) arguments (1:13)"
"throws": "Trailing comma is disallowed inside import(...) arguments (1:12)"
}

View File

@@ -157,7 +157,10 @@
},
"value": 123
}
]
],
"extra": {
"trailingComma": 24
}
}
}
],

View File

@@ -187,7 +187,6 @@
"column": 23
}
},
"attributes": [],
"name": {
"type": "JSXIdentifier",
"start": 29,
@@ -204,6 +203,7 @@
},
"name": "Foo"
},
"attributes": [],
"selfClosing": true
},
"closingElement": null,
@@ -263,7 +263,10 @@
]
}
}
]
],
"extra": {
"trailingComma": 39
}
}
}
],

View File

@@ -450,7 +450,10 @@
]
}
}
]
],
"extra": {
"trailingComma": 77
}
}
}
],