@samitouri / QOS-React-2 / commits / f17f4dcf0b

[hir] Treat values escaping into a contextref as Mutate

Sathya Gunasekaran committed Mar 3, 2023 at 13:35 UTC f17f4dcf0b27056c0474ec06eecf9970311ac823
1 file changed +5 -1
compiler/forget/src/Inference/InferReferenceEffects.ts
+5 -1
@@ -783,8 +783,12 @@ function inferBlock(
783 continue;
784 }
785 case "LoadLocal": {
786 - state.reference(instrValue.place, Effect.Capture);
786 const lvalue = instr.lvalue;
787 + const effect =
788 + state.isDefined(lvalue) && state.kind(lvalue) === ValueKind.Context
789 + ? Effect.Mutate
790 + : Effect.Capture;
791 + state.reference(instrValue.place, effect);
792 lvalue.effect = Effect.Mutate;
793 // direct aliasing: `a = b`;
794 state.alias(lvalue, instrValue.place);