[patch] Remove invalid invariant in deriveMinimalDeps
Confirmed that this fixes invariant violation on -
mofeiZ committed
Mar 30, 2023 at 17:33 UTC
5beecef28f0891e65cf229f5f26015b129ea9994
1 file changed
+8
-1
compiler/forget/src/ReactiveScopes/DeriveMinimalDependencies.ts
+8
-1
@@ -360,7 +360,10 @@ function demoteSubtreeToConditional(subtree: DependencyNode): void {
360
let node;
361
while ((node = stack.pop()) !== undefined) {
362
const { accessType, properties } = node;
363
- invariant(isUnconditional(accessType), "");
363
+ if (!isUnconditional(accessType)) {
364
+ // A conditionally accessed node should not have unconditional children
365
+ continue;
366
+ }
367
node.accessType = isDependency(accessType)
368
? PropertyAccessType.ConditionalDependency
369
: PropertyAccessType.ConditionalAccess;
@@ -385,6 +388,10 @@ function demoteSubtreeToConditional(subtree: DependencyNode): void {
388
* @param otherNode (move) {@link addSubtree} takes ownership of the subtree
389
* represented by otherNode, which may be mutated or moved to currNode. It is
390
* invalid to use otherNode after this call.
391
+ *
392
+ * Note that @param otherNode may contain both conditional and unconditional nodes,
393
+ * due to inner control flow and conditional member expressions
394
+ *
395
* @param demoteOtherNode
396
*/
397
function addSubtree(