@samitouri / QOS-React-2 / commits / 1e5e75746d

[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.

Sathya Gunasekaran committed Mar 3, 2023 at 13:35 UTC 1e5e75746d8d7a28634cabda2592cb4212320f1f
1 file changed +11
compiler/forget/src/HIR/BuildHIR.ts
+11
@@ -2160,6 +2160,17 @@ function gatherCapturedDeps(
2160 });
2161
2162 function visit(path: NodePath<Expression>): void {
2163 + // Babel has a bug where it doesn't visit the LHS of an
2164 + // AssignmentExpression if it's an Identifier. Work around it by explicitly
2165 + // visiting it.
2166 + if (path.isAssignmentExpression()) {
2167 + const left = path.get("left");
2168 + if (left.isIdentifier()) {
2169 + visit(left);
2170 + }
2171 + return;
2172 + }
2173 +
2174 let obj = path;
2175 while (obj.isMemberExpression()) {
2176 obj = obj.get("object");