mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
[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:
@@ -895,7 +895,7 @@ function codegenInstructionValue(
|
||||
break;
|
||||
}
|
||||
case "FunctionExpression": {
|
||||
value = instrValue.expr;
|
||||
value = t.cloneNode(instrValue.expr, true, true);
|
||||
break;
|
||||
}
|
||||
case "TaggedTemplateExpression": {
|
||||
|
||||
+1
@@ -23,6 +23,7 @@ function component(a) {
|
||||
(function () {
|
||||
y = x;
|
||||
})();
|
||||
|
||||
mutate(1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
+1
@@ -31,6 +31,7 @@ function Component() {
|
||||
const fn = function () {
|
||||
x = x + 1;
|
||||
};
|
||||
|
||||
fn();
|
||||
return 40;
|
||||
}
|
||||
|
||||
+1
@@ -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(", ");
|
||||
}
|
||||
|
||||
+1
@@ -33,6 +33,7 @@ function component(foo, bar) {
|
||||
let b = x;
|
||||
a.x = b;
|
||||
})();
|
||||
|
||||
mutate(y);
|
||||
$[0] = foo;
|
||||
$[1] = bar;
|
||||
|
||||
+1
@@ -33,6 +33,7 @@ function component(foo, bar) {
|
||||
let b = x;
|
||||
a.x = b;
|
||||
})();
|
||||
|
||||
mutate(y);
|
||||
$[0] = foo;
|
||||
$[1] = bar;
|
||||
|
||||
+1
@@ -33,6 +33,7 @@ function component(foo, bar) {
|
||||
let b = x;
|
||||
a.x = b;
|
||||
})();
|
||||
|
||||
mutate(y);
|
||||
$[0] = foo;
|
||||
$[1] = bar;
|
||||
|
||||
+1
@@ -33,6 +33,7 @@ function component(foo, bar) {
|
||||
let b = x;
|
||||
a.x = b;
|
||||
})();
|
||||
|
||||
mutate(y);
|
||||
$[0] = foo;
|
||||
$[1] = bar;
|
||||
|
||||
+1
@@ -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;
|
||||
|
||||
+1
@@ -30,6 +30,7 @@ function component(a) {
|
||||
let a_0 = y;
|
||||
a_0["x"] = x;
|
||||
})();
|
||||
|
||||
mutate(y);
|
||||
$[0] = a;
|
||||
$[1] = y;
|
||||
|
||||
+1
@@ -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;
|
||||
|
||||
+1
@@ -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;
|
||||
|
||||
+1
@@ -54,6 +54,7 @@ function CaptureNotMutate(props) {
|
||||
const arr = { element };
|
||||
return arr[idx];
|
||||
};
|
||||
|
||||
aliasedElement = fn();
|
||||
mutate(aliasedElement);
|
||||
$[2] = props.el;
|
||||
|
||||
+1
@@ -35,6 +35,7 @@ function Component() {
|
||||
const fn = function () {
|
||||
mutate(x_0);
|
||||
};
|
||||
|
||||
fn();
|
||||
return x;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user