Add back transitive freeze functions option

Adds back a mode to transitively freeze function expressions, independently from 
the mode to preserve existing manual memoization. This lets us experiment with a 
few variants: 

* Preserve existing memoization 

* Validate existing memoization with: 

* `enableAssumeHooksFollowRulesOfReact` && 
`enableTransitivelyFreezeFunctionExpressions` 

* `enableAssumeHooksFollowRulesOfReact` only 

* neither of those flags 

Note that `enableTransitivelyFreezeFunctionExpressions` alone probably doesn't 
make sense, it's more aggressive than 

`enableAssumeHooksFollowRulesOfReact` so we might as well try them together.
This commit is contained in:
Joe Savona
2023-12-18 15:33:02 -08:00
parent c77acb3ac6
commit f504eaa16e
4 changed files with 15 additions and 4 deletions
@@ -354,7 +354,10 @@ class InferenceState {
reason: reasonSet,
});
if (this.#env.config.enablePreserveExistingMemoizationGuarantees) {
if (
this.#env.config.enablePreserveExistingMemoizationGuarantees ||
this.#env.config.enableTransitivelyFreezeFunctionExpressions
) {
if (value.kind === "FunctionExpression") {
for (const operand of eachInstructionValueOperand(value)) {
this.reference(operand, Effect.Freeze, ValueReason.Other);