From 1e5e75746d8d7a28634cabda2592cb4212320f1f Mon Sep 17 00:00:00 2001 From: Sathya Gunasekaran Date: Fri, 3 Mar 2023 13:35:04 +0000 Subject: [PATCH] [hir] Handle LHS of AssignmentExpression specially Babel has a bug where it doesn't visit the LHS of an AssignmentExpression if it's an Identifier. Work around it by explicitly visiting it. --- compiler/forget/src/HIR/BuildHIR.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/compiler/forget/src/HIR/BuildHIR.ts b/compiler/forget/src/HIR/BuildHIR.ts index 0f78212dc0..c5eea2ea2e 100644 --- a/compiler/forget/src/HIR/BuildHIR.ts +++ b/compiler/forget/src/HIR/BuildHIR.ts @@ -2160,6 +2160,17 @@ function gatherCapturedDeps( }); function visit(path: NodePath): void { + // Babel has a bug where it doesn't visit the LHS of an + // AssignmentExpression if it's an Identifier. Work around it by explicitly + // visiting it. + if (path.isAssignmentExpression()) { + const left = path.get("left"); + if (left.isIdentifier()) { + visit(left); + } + return; + } + let obj = path; while (obj.isMemberExpression()) { obj = obj.get("object");