[hir] Clone babel nodes rather than reusing them

There's state such as scope info sticking on to these nodes so reusing them can 
cause issues if a pass later on just uses scopes these directly.
This commit is contained in:
Sathya Gunasekaran
2023-04-27 17:35:30 +01:00
parent 4a8c90a77c
commit 1cccd6a815
22 changed files with 22 additions and 4 deletions
@@ -895,7 +895,7 @@ function codegenInstructionValue(
break;
}
case "FunctionExpression": {
value = instrValue.expr;
value = t.cloneNode(instrValue.expr, true, true);
break;
}
case "TaggedTemplateExpression": {
@@ -23,6 +23,7 @@ function component(a) {
(function () {
y = x;
})();
mutate(1);
return 1;
}
@@ -31,6 +31,7 @@ function Component() {
const fn = function () {
x = x + 1;
};
fn();
return 40;
}
@@ -34,6 +34,7 @@ function Component() {
const fn = function () {
x_0 = 42;
};
fn();
return x;
}
@@ -58,9 +58,7 @@ function getNativeLogFunction(level) {
} else {
str = Array.prototype.map
.call(arguments, function (arg) {
return inspect(arg, {
depth: 10,
});
return inspect(arg, { depth: 10 });
})
.join(", ");
}
@@ -33,6 +33,7 @@ function component(foo, bar) {
let b = x;
a.x = b;
})();
mutate(y);
$[0] = foo;
$[1] = bar;
@@ -33,6 +33,7 @@ function component(foo, bar) {
let b = x;
a.x = b;
})();
mutate(y);
$[0] = foo;
$[1] = bar;
@@ -33,6 +33,7 @@ function component(foo, bar) {
let b = x;
a.x = b;
})();
mutate(y);
$[0] = foo;
$[1] = bar;
@@ -33,6 +33,7 @@ function component(foo, bar) {
let b = x;
a.x = b;
})();
mutate(y);
$[0] = foo;
$[1] = bar;
@@ -28,6 +28,7 @@ function component(a) {
(function () {
y["x"] = x;
})();
mutate(y);
$[0] = a;
$[1] = y;
@@ -28,6 +28,7 @@ function component(a) {
(function () {
y.x = x;
})();
mutate(y);
$[0] = a;
$[1] = y;
@@ -30,6 +30,7 @@ function component(a) {
let a_0 = y;
a_0["x"] = x;
})();
mutate(y);
$[0] = a;
$[1] = y;
@@ -30,6 +30,7 @@ function component(a) {
let a_0 = y;
a_0.x = x;
})();
mutate(y);
$[0] = a;
$[1] = y;
@@ -40,6 +40,7 @@ function component(a, b) {
z.a = 2;
y.b;
};
x();
$[2] = a;
$[3] = y.b;
@@ -26,6 +26,7 @@ function component(a) {
x = function () {
y.b.a = 2;
};
x();
$[0] = a;
$[1] = x;
@@ -40,6 +40,7 @@ function component(a, b) {
z.a = 2;
y.b;
};
x();
$[0] = a;
$[1] = b;
@@ -28,6 +28,7 @@ function component(a) {
(function () {
y = x;
})();
mutate(y);
$[0] = a;
$[1] = y;
@@ -37,6 +37,7 @@ function component(a, b) {
} else {
z = $[1];
}
let y = z;
const c_2 = $[2] !== b;
let t0;
@@ -26,6 +26,7 @@ function component(a) {
const x = function x() {
t.foo();
};
x(t);
$[0] = a;
$[1] = t;
@@ -33,6 +33,7 @@ function component(a) {
t0 = $[2];
}
const x = t0;
x(t);
$[0] = a;
$[1] = t;
@@ -54,6 +54,7 @@ function CaptureNotMutate(props) {
const arr = { element };
return arr[idx];
};
aliasedElement = fn();
mutate(aliasedElement);
$[2] = props.el;
@@ -35,6 +35,7 @@ function Component() {
const fn = function () {
mutate(x_0);
};
fn();
return x;
}