diff --git a/compiler/forget/src/HIR/HIRBuilder.ts b/compiler/forget/src/HIR/HIRBuilder.ts index 76a2c61f6e..bd39ffee1b 100644 --- a/compiler/forget/src/HIR/HIRBuilder.ts +++ b/compiler/forget/src/HIR/HIRBuilder.ts @@ -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 { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/_bug.lambda-reassign-shadowed-primitive.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/_bug.lambda-reassign-shadowed-primitive.expect.md index 8a917699fd..3655fff153 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/_bug.lambda-reassign-shadowed-primitive.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/_bug.lambda-reassign-shadowed-primitive.expect.md @@ -31,7 +31,7 @@ function Component() { const x = t0; const fn = function () { - x = 42; + x_0 = 42; }; fn(); return x; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/_bug.capturing-function-renamed-ref.js b/compiler/forget/src/__tests__/fixtures/compiler/capturing-function-renamed-ref similarity index 100% rename from compiler/forget/src/__tests__/fixtures/compiler/_bug.capturing-function-renamed-ref.js rename to compiler/forget/src/__tests__/fixtures/compiler/capturing-function-renamed-ref diff --git a/compiler/forget/src/__tests__/fixtures/compiler/_bug.capturing-function-renamed-ref.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/capturing-function-renamed-ref.expect.md similarity index 96% rename from compiler/forget/src/__tests__/fixtures/compiler/_bug.capturing-function-renamed-ref.expect.md rename to compiler/forget/src/__tests__/fixtures/compiler/capturing-function-renamed-ref.expect.md index d2f4fdc4b9..41a0241da9 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/_bug.capturing-function-renamed-ref.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/capturing-function-renamed-ref.expect.md @@ -33,7 +33,7 @@ function component(a, b) { const z_0 = { b }; (function () { - mutate(z); + mutate(z_0); })(); return z; } diff --git a/compiler/forget/src/__tests__/fixtures/compiler/_bug.lambda-mutate-shadowed-object.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/lambda-mutate-shadowed-object.expect.md similarity index 96% rename from compiler/forget/src/__tests__/fixtures/compiler/_bug.lambda-mutate-shadowed-object.expect.md rename to compiler/forget/src/__tests__/fixtures/compiler/lambda-mutate-shadowed-object.expect.md index 042e24d871..402749fe4e 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/_bug.lambda-mutate-shadowed-object.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/lambda-mutate-shadowed-object.expect.md @@ -32,7 +32,7 @@ function Component() { const x_0 = []; const fn = function () { - mutate(x); + mutate(x_0); }; fn(); return x; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/_bug.lambda-mutate-shadowed-object.js b/compiler/forget/src/__tests__/fixtures/compiler/lambda-mutate-shadowed-object.js similarity index 100% rename from compiler/forget/src/__tests__/fixtures/compiler/_bug.lambda-mutate-shadowed-object.js rename to compiler/forget/src/__tests__/fixtures/compiler/lambda-mutate-shadowed-object.js