[be][DeriveMinimalDeps] Check current assumptions for conditional control flow
Mofei Zhang committed
Mar 27, 2024 at 20:26 UTC
a37f242f593c685f0a71a8ff35d9f0ebd4e8391a
2 files changed
+18
-2
compiler/packages/babel-plugin-react-forget/src/ReactiveScopes/DeriveMinimalDependencies.ts
+17
-1
@@ -6,7 +6,7 @@
6
*/
7
8
import { CompilerError } from "../CompilerError";
9
-import { Identifier, ReactiveScopeDependency } from "../HIR";
9
+import { GeneratedSource, Identifier, ReactiveScopeDependency } from "../HIR";
10
import { printIdentifier } from "../HIR/PrintHIR";
11
import { assertExhaustive } from "../Utils/utils";
12
@@ -490,6 +490,22 @@ function addSubtreeIntersection(
490
suggestions: null,
491
});
492
493
+ CompilerError.invariant(
494
+ otherProperties.every((otherNode) => {
495
+ for (const [_, node] of otherNode) {
496
+ if (!isUnconditional(node.accessType)) {
497
+ return false;
498
+ }
499
+ }
500
+ return true;
501
+ }),
502
+ {
503
+ reason:
504
+ "[DeriveMinimalDependencies] Expected otherProperties to only hold unconditional nodes",
505
+ loc: GeneratedSource,
506
+ }
507
+ );
508
+
509
/*
510
* otherProperties here may contain unconditional nodes as the result of
511
* recursively merging exhaustively conditional children with unconditionally
compiler/packages/babel-plugin-react-forget/src/ReactiveScopes/PropagateScopeDependencies.ts
+1
-1
@@ -446,7 +446,7 @@ class Context {
446
}
447
448
if (this.#checkValidDependency(maybeDependency)) {
449
- this.#depsInCurrentConditional.add(maybeDependency, true);
449
+ this.#depsInCurrentConditional.add(maybeDependency, false);
450
/*
451
* Add info about this dependency to the existing tree
452
* We do not try to join/reduce dependencies here due to missing info