[hir] Try to resolve a dep into a property load only if it's a temporary.
Sathya Gunasekaran committed
Jan 26, 2023 at 16:40 UTC
41e8088e8c20b07d4e0a96fb9066839196efaeca
3 files changed
+8
-4
compiler/forget/src/ReactiveScopes/PropagateScopeDependencies.ts
+6
-2
@@ -110,8 +110,12 @@ class Context {
110
} else {
111
// Otherwise if this operand is a temporary created for a property load, resolve it to
112
// the expanded Place. Fall back to using the operand as-is.
113
- maybeDependency =
114
- this.#properties.get(dependency.place.identifier) ?? dependency;
113
+ let propDep = this.#properties.get(dependency.place.identifier);
114
+ if (dependency.place.identifier.name === null && propDep !== undefined) {
115
+ maybeDependency = propDep;
116
+ } else {
117
+ maybeDependency = dependency;
118
+ }
119
}
120
121
const decl = this.#declarations.get(maybeDependency.place.identifier);
compiler/forget/src/__tests__/fixtures/hir/bug_object-pattern.expect.md
renamed
+2
-2
@@ -16,11 +16,11 @@ function component(t) {
16
function component(t) {
17
const $ = React.useMemoCache();
18
const a = t.a;
19
- const c_0 = $[0] !== t6.a;
19
+ const c_0 = $[0] !== a;
20
let y;
21
if (c_0) {
22
y = { a: a };
23
- $[0] = t6.a;
23
+ $[0] = a;
24
$[1] = y;
25
} else {
26
y = $[1];