Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Exclude catch clause from let identifier error (#10559)
* Exclude catch clause from let identifier error * Disallow let binding based on parameter * Add test * Remove unused getter * Update packages/babel-parser/src/parser/statement.js Co-Authored-By: Nicol貌 Ribaudo <nicolo.ribaudo@gmail.com>
- Loading branch information
1 parent
487f10f
commit 095f28a
Showing
7 changed files
with
139 additions
and
3 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
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
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: 3 additions & 0 deletions
3
packages/babel-parser/test/fixtures/es2015/let/let-at-catch-block/input.js
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,3 @@ | ||
try {} catch (err) { | ||
let let; | ||
} |
3 changes: 3 additions & 0 deletions
3
packages/babel-parser/test/fixtures/es2015/let/let-at-catch-block/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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"throws": "'let' is not allowed to be used as a name in 'let' or 'const' declarations. (2:6)" | ||
} |
1 change: 1 addition & 0 deletions
1
packages/babel-parser/test/fixtures/es2015/let/try-catch-let/input.js
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 @@ | ||
try {} catch (let) {} |
117 changes: 117 additions & 0 deletions
117
packages/babel-parser/test/fixtures/es2015/let/try-catch-let/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,117 @@ | ||
{ | ||
"type": "File", | ||
"start": 0, | ||
"end": 21, | ||
"loc": { | ||
"start": { | ||
"line": 1, | ||
"column": 0 | ||
}, | ||
"end": { | ||
"line": 1, | ||
"column": 21 | ||
} | ||
}, | ||
"program": { | ||
"type": "Program", | ||
"start": 0, | ||
"end": 21, | ||
"loc": { | ||
"start": { | ||
"line": 1, | ||
"column": 0 | ||
}, | ||
"end": { | ||
"line": 1, | ||
"column": 21 | ||
} | ||
}, | ||
"sourceType": "script", | ||
"interpreter": null, | ||
"body": [ | ||
{ | ||
"type": "TryStatement", | ||
"start": 0, | ||
"end": 21, | ||
"loc": { | ||
"start": { | ||
"line": 1, | ||
"column": 0 | ||
}, | ||
"end": { | ||
"line": 1, | ||
"column": 21 | ||
} | ||
}, | ||
"block": { | ||
"type": "BlockStatement", | ||
"start": 4, | ||
"end": 6, | ||
"loc": { | ||
"start": { | ||
"line": 1, | ||
"column": 4 | ||
}, | ||
"end": { | ||
"line": 1, | ||
"column": 6 | ||
} | ||
}, | ||
"body": [], | ||
"directives": [] | ||
}, | ||
"handler": { | ||
"type": "CatchClause", | ||
"start": 7, | ||
"end": 21, | ||
"loc": { | ||
"start": { | ||
"line": 1, | ||
"column": 7 | ||
}, | ||
"end": { | ||
"line": 1, | ||
"column": 21 | ||
} | ||
}, | ||
"param": { | ||
"type": "Identifier", | ||
"start": 14, | ||
"end": 17, | ||
"loc": { | ||
"start": { | ||
"line": 1, | ||
"column": 14 | ||
}, | ||
"end": { | ||
"line": 1, | ||
"column": 17 | ||
}, | ||
"identifierName": "let" | ||
}, | ||
"name": "let" | ||
}, | ||
"body": { | ||
"type": "BlockStatement", | ||
"start": 19, | ||
"end": 21, | ||
"loc": { | ||
"start": { | ||
"line": 1, | ||
"column": 19 | ||
}, | ||
"end": { | ||
"line": 1, | ||
"column": 21 | ||
} | ||
}, | ||
"body": [], | ||
"directives": [] | ||
} | ||
}, | ||
"finalizer": null | ||
} | ||
], | ||
"directives": [] | ||
} | ||
} |