Skip to content

Commit

Permalink
Fix tdz analysis for reassigned captured for bindings (#15278)
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolo-ribaudo authored Dec 16, 2022
1 parent 0259335 commit 2dd8254
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,9 @@ function getTDZReplacement(
if (skipTDZChecks.has(id)) return;
skipTDZChecks.add(id);

const bindingPath = path.scope.getBinding(id.name).path;
const bindingPath = path.scope.getBinding(id.name)?.path;

if (bindingPath.isFunctionDeclaration()) return;
if (!bindingPath || bindingPath.isFunctionDeclaration()) return;

const status = getTDZStatus(path, bindingPath);
if (status === "outside") return;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
for (let index = 0; index < 10; index++) {
index++;
() => index;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"plugins": [["transform-block-scoping", { "tdz": true }]]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
var _loop = function (_index) {
_index++;
() => _index;
index = _index;
};
for (var index = 0; index < 10; index++) {
_loop(index);
}

0 comments on commit 2dd8254

Please sign in to comment.