Nicolò Ribaudo 87feda7c2a
@babel/parser error recovery (#10363)
* Add error recovery support to @babel/parser

* Update @babel/parser tests to always recover from errors

* Update this.raise usage in @babel/parser:

- expression.js
- lval.js
- statement.js
- estree.js
- flow.js
- jsx/index.js
- tokenizer/index.js

* Update @babel/parser fixtures with recovered errors

* Fix tests out of @babel/parser

* Do not use try/catch for control flow

* Update invalid fixtures

* Do not report invalid lhs in toAssignable

* Do not validate function id multiple times

* Dedupe reserved await errors

* Remove duplicate errors about strict reserved bindings

* Remove duplicated error about yield/await inside params

* Don't error twice for methods in object patterns

* Don't report invalid super() twice

* Remove dup error about reserved param for expr arrows

* Remove double escapes in migrated tests

* Dedupe errors about invalid escapes in identifiers

* Remove duplicated error about decorated constructor

* Remove duplicated error about spread in flow class

* Don't throw for invalid super usage

* Don't fail for object decorators with stage 2

* Fix flow inexact type errors

* Fix flow

* Fix errors about escapes in keywords (ref: #10455)

* Update after rebase

* Fix todo

* Remove duplicated error when using += for defaults

* Remove unnecessary throw

* Nit: use ??
2019-11-05 10:15:00 +01:00

556 lines
18 KiB
JSON

{
"type": "File",
"start": 0,
"end": 103,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 76
}
},
"errors": [
"SyntaxError: Identifier 'foo4' has already been declared (2:58)",
"SyntaxError: `foo4` has already been exported. Exported identifiers must be unique. (2:58)"
],
"program": {
"type": "Program",
"start": 0,
"end": 103,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 76
}
},
"sourceType": "module",
"interpreter": null,
"body": [
{
"type": "ExportNamedDeclaration",
"start": 0,
"end": 25,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 25
}
},
"specifiers": [],
"source": null,
"declaration": {
"type": "FunctionDeclaration",
"start": 7,
"end": 25,
"loc": {
"start": {
"line": 1,
"column": 7
},
"end": {
"line": 1,
"column": 25
}
},
"id": {
"type": "Identifier",
"start": 16,
"end": 20,
"loc": {
"start": {
"line": 1,
"column": 16
},
"end": {
"line": 1,
"column": 20
},
"identifierName": "foo4"
},
"name": "foo4"
},
"generator": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 23,
"end": 25,
"loc": {
"start": {
"line": 1,
"column": 23
},
"end": {
"line": 1,
"column": 25
}
},
"body": [],
"directives": []
}
}
},
{
"type": "EmptyStatement",
"start": 25,
"end": 26,
"loc": {
"start": {
"line": 1,
"column": 25
},
"end": {
"line": 1,
"column": 26
}
}
},
{
"type": "ExportNamedDeclaration",
"start": 27,
"end": 103,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 76
}
},
"specifiers": [],
"source": null,
"declaration": {
"type": "VariableDeclaration",
"start": 34,
"end": 103,
"loc": {
"start": {
"line": 2,
"column": 7
},
"end": {
"line": 2,
"column": 76
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 40,
"end": 102,
"loc": {
"start": {
"line": 2,
"column": 13
},
"end": {
"line": 2,
"column": 75
}
},
"id": {
"type": "ObjectPattern",
"start": 40,
"end": 96,
"loc": {
"start": {
"line": 2,
"column": 13
},
"end": {
"line": 2,
"column": 69
}
},
"properties": [
{
"type": "ObjectProperty",
"start": 42,
"end": 60,
"loc": {
"start": {
"line": 2,
"column": 15
},
"end": {
"line": 2,
"column": 33
}
},
"method": false,
"key": {
"type": "Identifier",
"start": 42,
"end": 43,
"loc": {
"start": {
"line": 2,
"column": 15
},
"end": {
"line": 2,
"column": 16
},
"identifierName": "a"
},
"name": "a"
},
"computed": false,
"shorthand": false,
"value": {
"type": "ArrayPattern",
"start": 45,
"end": 60,
"loc": {
"start": {
"line": 2,
"column": 18
},
"end": {
"line": 2,
"column": 33
}
},
"elements": [
{
"type": "ObjectPattern",
"start": 46,
"end": 59,
"loc": {
"start": {
"line": 2,
"column": 19
},
"end": {
"line": 2,
"column": 32
}
},
"properties": [
{
"type": "ObjectProperty",
"start": 48,
"end": 57,
"loc": {
"start": {
"line": 2,
"column": 21
},
"end": {
"line": 2,
"column": 30
}
},
"method": false,
"key": {
"type": "Identifier",
"start": 48,
"end": 52,
"loc": {
"start": {
"line": 2,
"column": 21
},
"end": {
"line": 2,
"column": 25
},
"identifierName": "foo4"
},
"name": "foo4"
},
"computed": false,
"shorthand": false,
"value": {
"type": "Identifier",
"start": 54,
"end": 57,
"loc": {
"start": {
"line": 2,
"column": 27
},
"end": {
"line": 2,
"column": 30
},
"identifierName": "foo"
},
"name": "foo"
}
}
]
}
]
}
},
{
"type": "ObjectProperty",
"start": 62,
"end": 63,
"loc": {
"start": {
"line": 2,
"column": 35
},
"end": {
"line": 2,
"column": 36
}
},
"method": false,
"key": {
"type": "Identifier",
"start": 62,
"end": 63,
"loc": {
"start": {
"line": 2,
"column": 35
},
"end": {
"line": 2,
"column": 36
},
"identifierName": "b"
},
"name": "b"
},
"computed": false,
"shorthand": true,
"value": {
"type": "Identifier",
"start": 62,
"end": 63,
"loc": {
"start": {
"line": 2,
"column": 35
},
"end": {
"line": 2,
"column": 36
},
"identifierName": "b"
},
"name": "b"
},
"extra": {
"shorthand": true
}
},
{
"type": "ObjectProperty",
"start": 65,
"end": 94,
"loc": {
"start": {
"line": 2,
"column": 38
},
"end": {
"line": 2,
"column": 67
}
},
"method": false,
"key": {
"type": "Identifier",
"start": 65,
"end": 66,
"loc": {
"start": {
"line": 2,
"column": 38
},
"end": {
"line": 2,
"column": 39
},
"identifierName": "c"
},
"name": "c"
},
"computed": false,
"shorthand": false,
"value": {
"type": "ObjectPattern",
"start": 68,
"end": 94,
"loc": {
"start": {
"line": 2,
"column": 41
},
"end": {
"line": 2,
"column": 67
}
},
"properties": [
{
"type": "ObjectProperty",
"start": 70,
"end": 92,
"loc": {
"start": {
"line": 2,
"column": 43
},
"end": {
"line": 2,
"column": 65
}
},
"method": false,
"key": {
"type": "Identifier",
"start": 70,
"end": 74,
"loc": {
"start": {
"line": 2,
"column": 43
},
"end": {
"line": 2,
"column": 47
},
"identifierName": "foo2"
},
"name": "foo2"
},
"computed": false,
"shorthand": false,
"value": {
"type": "ArrayPattern",
"start": 76,
"end": 92,
"loc": {
"start": {
"line": 2,
"column": 49
},
"end": {
"line": 2,
"column": 65
}
},
"elements": [
{
"type": "ObjectPattern",
"start": 77,
"end": 91,
"loc": {
"start": {
"line": 2,
"column": 50
},
"end": {
"line": 2,
"column": 64
}
},
"properties": [
{
"type": "ObjectProperty",
"start": 79,
"end": 89,
"loc": {
"start": {
"line": 2,
"column": 52
},
"end": {
"line": 2,
"column": 62
}
},
"method": false,
"key": {
"type": "Identifier",
"start": 79,
"end": 83,
"loc": {
"start": {
"line": 2,
"column": 52
},
"end": {
"line": 2,
"column": 56
},
"identifierName": "foo3"
},
"name": "foo3"
},
"computed": false,
"shorthand": false,
"value": {
"type": "Identifier",
"start": 85,
"end": 89,
"loc": {
"start": {
"line": 2,
"column": 58
},
"end": {
"line": 2,
"column": 62
},
"identifierName": "foo4"
},
"name": "foo4"
}
}
]
}
]
}
}
]
}
}
]
},
"init": {
"type": "Identifier",
"start": 99,
"end": 102,
"loc": {
"start": {
"line": 2,
"column": 72
},
"end": {
"line": 2,
"column": 75
},
"identifierName": "bar"
},
"name": "bar"
}
}
],
"kind": "const"
}
}
],
"directives": []
}
}