diff --git a/compiler/forget/packages/babel-plugin-react-forget/src/HIR/HIR.ts b/compiler/forget/packages/babel-plugin-react-forget/src/HIR/HIR.ts index b02016ebd6..05b80f1bd8 100644 --- a/compiler/forget/packages/babel-plugin-react-forget/src/HIR/HIR.ts +++ b/compiler/forget/packages/babel-plugin-react-forget/src/HIR/HIR.ts @@ -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); } diff --git a/compiler/forget/packages/babel-plugin-react-forget/src/Inference/InferReferenceEffects.ts b/compiler/forget/packages/babel-plugin-react-forget/src/Inference/InferReferenceEffects.ts index 91b4fcd879..4aab1f122b 100644 --- a/compiler/forget/packages/babel-plugin-react-forget/src/Inference/InferReferenceEffects.ts +++ b/compiler/forget/packages/babel-plugin-react-forget/src/Inference/InferReferenceEffects.ts @@ -311,7 +311,7 @@ class InferenceState { valueKind === ValueKind.Mutable || valueKind === ValueKind.Context ) { - effect = Effect.Mutate; + effect = Effect.ConditionallyMutate; } else { effect = Effect.Read; } diff --git a/compiler/forget/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.invalid-pass-ref-to-function.expect.md b/compiler/forget/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.invalid-pass-ref-to-function.expect.md index 54cb17b425..f9cab45985 100644 --- a/compiler/forget/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.invalid-pass-ref-to-function.expect.md +++ b/compiler/forget/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.invalid-pass-ref-to-function.expect.md @@ -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 (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 (3:3) ``` \ No newline at end of file