From 5beecef28f0891e65cf229f5f26015b129ea9994 Mon Sep 17 00:00:00 2001 From: mofeiZ <34200447+mofeiZ@users.noreply.github.com> Date: Thu, 30 Mar 2023 17:33:37 -0400 Subject: [PATCH] [patch] Remove invalid invariant in deriveMinimalDeps Confirmed that this fixes invariant violation on - --- .../src/ReactiveScopes/DeriveMinimalDependencies.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/compiler/forget/src/ReactiveScopes/DeriveMinimalDependencies.ts b/compiler/forget/src/ReactiveScopes/DeriveMinimalDependencies.ts index 35c923acd2..9a2e7cbc85 100644 --- a/compiler/forget/src/ReactiveScopes/DeriveMinimalDependencies.ts +++ b/compiler/forget/src/ReactiveScopes/DeriveMinimalDependencies.ts @@ -360,7 +360,10 @@ function demoteSubtreeToConditional(subtree: DependencyNode): void { let node; while ((node = stack.pop()) !== undefined) { const { accessType, properties } = node; - invariant(isUnconditional(accessType), ""); + if (!isUnconditional(accessType)) { + // A conditionally accessed node should not have unconditional children + continue; + } node.accessType = isDependency(accessType) ? PropertyAccessType.ConditionalDependency : PropertyAccessType.ConditionalAccess; @@ -385,6 +388,10 @@ function demoteSubtreeToConditional(subtree: DependencyNode): void { * @param otherNode (move) {@link addSubtree} takes ownership of the subtree * represented by otherNode, which may be mutated or moved to currNode. It is * invalid to use otherNode after this call. + * + * Note that @param otherNode may contain both conditional and unconditional nodes, + * due to inner control flow and conditional member expressions + * * @param demoteOtherNode */ function addSubtree(