mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
[hir] Rewrite identifiers to be consistent
If we resolve identifiers to be different from the binding, update the binding to the new name.
This commit is contained in:
@@ -219,7 +219,11 @@ export default class HIRBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
return this.resolveBinding(binding.identifier);
|
||||
const resolvedBinding = this.resolveBinding(binding.identifier);
|
||||
if (resolvedBinding.name && resolvedBinding.name !== originalName) {
|
||||
binding.scope.rename(originalName, resolvedBinding.name);
|
||||
}
|
||||
return resolvedBinding;
|
||||
}
|
||||
|
||||
resolveBinding(node: t.Identifier): Identifier {
|
||||
|
||||
+1
-1
@@ -31,7 +31,7 @@ function Component() {
|
||||
const x = t0;
|
||||
|
||||
const fn = function () {
|
||||
x = 42;
|
||||
x_0 = 42;
|
||||
};
|
||||
fn();
|
||||
return x;
|
||||
|
||||
+1
-1
@@ -33,7 +33,7 @@ function component(a, b) {
|
||||
|
||||
const z_0 = { b };
|
||||
(function () {
|
||||
mutate(z);
|
||||
mutate(z_0);
|
||||
})();
|
||||
return z;
|
||||
}
|
||||
+1
-1
@@ -32,7 +32,7 @@ function Component() {
|
||||
|
||||
const x_0 = [];
|
||||
const fn = function () {
|
||||
mutate(x);
|
||||
mutate(x_0);
|
||||
};
|
||||
fn();
|
||||
return x;
|
||||
Reference in New Issue
Block a user