InferReferenceEffects: distinguish conditional mutations in HIR

In InferReferenceEffects, locations that are ConditionallyMutate are either 
recorded as a Mutate or Read, which means we lose the distinction btw 
conditional/unconditional mutation in later passes. This PR changes to remember 
that these places were conditionally mutable, used in later analysis.
This commit is contained in:
Joe Savona
2023-06-16 14:42:16 -07:00
parent 19976d5f83
commit 1db2619807
3 changed files with 4 additions and 9 deletions
@@ -878,16 +878,11 @@ export function isMutableEffect(
switch (effect) {
case Effect.Capture:
case Effect.Store:
case Effect.ConditionallyMutate:
case Effect.Mutate: {
return true;
}
case Effect.ConditionallyMutate: {
// All conditional mutations should be resolved into some other effect after InferReferenceEffects
CompilerError.invariant(
"Unexpected conditional mutation effect",
location
);
}
case Effect.Unknown: {
CompilerError.invariant("Unexpected unknown effect", location);
}
@@ -311,7 +311,7 @@ class InferenceState {
valueKind === ValueKind.Mutable ||
valueKind === ValueKind.Context
) {
effect = Effect.Mutate;
effect = Effect.ConditionallyMutate;
} else {
effect = Effect.Read;
}
@@ -14,7 +14,7 @@ function Component(props) {
## Error
```
[ReactForget] InvalidInput: Ref values may not be passed to functions because they could read the ref value (`current` property) during render. Cannot access ref object at mutate $22[6:8]:TObject<BuiltInUseRefId> (3:3)
[ReactForget] InvalidInput: Ref values may not be passed to functions because they could read the ref value (`current` property) during render. Cannot access ref object at mutate? $22[6:8]:TObject<BuiltInUseRefId> (3:3)
```