Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Recover from error for missing initializer in const declaration (#12120)
- Loading branch information
1 parent
3ba1ece
commit 45f0cc2
Showing
10 changed files
with
175 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 0 additions & 3 deletions
3
packages/babel-parser/test/fixtures/core/uncategorised/536/options.json
This file was deleted.
Oops, something went wrong.
33 changes: 33 additions & 0 deletions
33
packages/babel-parser/test/fixtures/core/uncategorised/536/output.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{ | ||
"type": "File", | ||
"start":0,"end":8,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":8}}, | ||
"errors": [ | ||
"SyntaxError: Const declarations require an initialization value (1:7)" | ||
], | ||
"program": { | ||
"type": "Program", | ||
"start":0,"end":8,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":8}}, | ||
"sourceType": "script", | ||
"interpreter": null, | ||
"body": [ | ||
{ | ||
"type": "VariableDeclaration", | ||
"start":0,"end":8,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":8}}, | ||
"declarations": [ | ||
{ | ||
"type": "VariableDeclarator", | ||
"start":6,"end":7,"loc":{"start":{"line":1,"column":6},"end":{"line":1,"column":7}}, | ||
"id": { | ||
"type": "Identifier", | ||
"start":6,"end":7,"loc":{"start":{"line":1,"column":6},"end":{"line":1,"column":7},"identifierName":"a"}, | ||
"name": "a" | ||
}, | ||
"init": null | ||
} | ||
], | ||
"kind": "const" | ||
} | ||
], | ||
"directives": [] | ||
} | ||
} |
4 changes: 2 additions & 2 deletions
4
packages/babel-parser/test/fixtures/esprima/es2015-for-of/unexpected-number/options.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
{ | ||
"throws": "Unexpected token (1:14)" | ||
} | ||
"throws": "Unexpected token, expected \";\" (1:14)" | ||
} |
3 changes: 0 additions & 3 deletions
3
packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0138/options.json
This file was deleted.
Oops, something went wrong.
51 changes: 51 additions & 0 deletions
51
packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0138/output.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
{ | ||
"type": "File", | ||
"start":0,"end":16,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":16}}, | ||
"errors": [ | ||
"SyntaxError: Const declarations require an initialization value (1:15)" | ||
], | ||
"program": { | ||
"type": "Program", | ||
"start":0,"end":16,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":16}}, | ||
"sourceType": "script", | ||
"interpreter": null, | ||
"body": [ | ||
{ | ||
"type": "VariableDeclaration", | ||
"start":0,"end":16,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":16}}, | ||
"declarations": [ | ||
{ | ||
"type": "VariableDeclarator", | ||
"start":6,"end":12,"loc":{"start":{"line":1,"column":6},"end":{"line":1,"column":12}}, | ||
"id": { | ||
"type": "Identifier", | ||
"start":6,"end":7,"loc":{"start":{"line":1,"column":6},"end":{"line":1,"column":7},"identifierName":"x"}, | ||
"name": "x" | ||
}, | ||
"init": { | ||
"type": "NumericLiteral", | ||
"start":10,"end":12,"loc":{"start":{"line":1,"column":10},"end":{"line":1,"column":12}}, | ||
"extra": { | ||
"rawValue": 12, | ||
"raw": "12" | ||
}, | ||
"value": 12 | ||
} | ||
}, | ||
{ | ||
"type": "VariableDeclarator", | ||
"start":14,"end":15,"loc":{"start":{"line":1,"column":14},"end":{"line":1,"column":15}}, | ||
"id": { | ||
"type": "Identifier", | ||
"start":14,"end":15,"loc":{"start":{"line":1,"column":14},"end":{"line":1,"column":15},"identifierName":"y"}, | ||
"name": "y" | ||
}, | ||
"init": null | ||
} | ||
], | ||
"kind": "const" | ||
} | ||
], | ||
"directives": [] | ||
} | ||
} |
3 changes: 0 additions & 3 deletions
3
packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0139/options.json
This file was deleted.
Oops, something went wrong.
51 changes: 51 additions & 0 deletions
51
packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0139/output.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
{ | ||
"type": "File", | ||
"start":0,"end":16,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":16}}, | ||
"errors": [ | ||
"SyntaxError: Const declarations require an initialization value (1:7)" | ||
], | ||
"program": { | ||
"type": "Program", | ||
"start":0,"end":16,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":16}}, | ||
"sourceType": "script", | ||
"interpreter": null, | ||
"body": [ | ||
{ | ||
"type": "VariableDeclaration", | ||
"start":0,"end":16,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":16}}, | ||
"declarations": [ | ||
{ | ||
"type": "VariableDeclarator", | ||
"start":6,"end":7,"loc":{"start":{"line":1,"column":6},"end":{"line":1,"column":7}}, | ||
"id": { | ||
"type": "Identifier", | ||
"start":6,"end":7,"loc":{"start":{"line":1,"column":6},"end":{"line":1,"column":7},"identifierName":"x"}, | ||
"name": "x" | ||
}, | ||
"init": null | ||
}, | ||
{ | ||
"type": "VariableDeclarator", | ||
"start":9,"end":15,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":15}}, | ||
"id": { | ||
"type": "Identifier", | ||
"start":9,"end":10,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":10},"identifierName":"y"}, | ||
"name": "y" | ||
}, | ||
"init": { | ||
"type": "NumericLiteral", | ||
"start":13,"end":15,"loc":{"start":{"line":1,"column":13},"end":{"line":1,"column":15}}, | ||
"extra": { | ||
"rawValue": 12, | ||
"raw": "12" | ||
}, | ||
"value": 12 | ||
} | ||
} | ||
], | ||
"kind": "const" | ||
} | ||
], | ||
"directives": [] | ||
} | ||
} |
3 changes: 0 additions & 3 deletions
3
packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0140/options.json
This file was deleted.
Oops, something went wrong.
33 changes: 33 additions & 0 deletions
33
packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0140/output.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{ | ||
"type": "File", | ||
"start":0,"end":8,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":8}}, | ||
"errors": [ | ||
"SyntaxError: Const declarations require an initialization value (1:7)" | ||
], | ||
"program": { | ||
"type": "Program", | ||
"start":0,"end":8,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":8}}, | ||
"sourceType": "script", | ||
"interpreter": null, | ||
"body": [ | ||
{ | ||
"type": "VariableDeclaration", | ||
"start":0,"end":8,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":8}}, | ||
"declarations": [ | ||
{ | ||
"type": "VariableDeclarator", | ||
"start":6,"end":7,"loc":{"start":{"line":1,"column":6},"end":{"line":1,"column":7}}, | ||
"id": { | ||
"type": "Identifier", | ||
"start":6,"end":7,"loc":{"start":{"line":1,"column":6},"end":{"line":1,"column":7},"identifierName":"x"}, | ||
"name": "x" | ||
}, | ||
"init": null | ||
} | ||
], | ||
"kind": "const" | ||
} | ||
], | ||
"directives": [] | ||
} | ||
} |