You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
'All effects other than ImmutableFunctionCall should have been handled earlier',
359
+
loc: null,
360
+
});
361
+
if(
362
+
!usedIdentifiers.has(effect.lvalue)&&
363
+
(!effect.global||
364
+
!names.has(effect.callee)||
365
+
!allowedNames.has(names.get(effect.callee)!))
366
+
){
367
+
constname=names.get(effect.callee)??'(unknown)';
368
+
error.push({
369
+
reason: `Function \'${name}\' is called with arguments that React Compiler expects to be immutable and its return value is ignored. This call is likely to perform unsafe side effects, which violates the rules of React.`,
370
+
loc: effect.loc,
371
+
severity: ErrorSeverity.InvalidReact,
372
+
});
373
+
}
374
+
}
375
+
376
+
if(error.hasErrors()){
377
+
throwerror;
378
+
}
379
+
}
263
380
}
381
+
fn.effects=functionEffects;
264
382
}
265
383
266
384
// Maintains a mapping of top-level variables to the kind of value they hold
@@ -409,11 +527,12 @@ class InferenceState {
409
527
for(consteffectofvalue.loweredFunc.func.effects){
410
528
if(
411
529
effect.kind==='GlobalMutation'||
412
-
effect.kind==='ReactMutation'
530
+
effect.kind==='ReactMutation'||
531
+
effect.kind==='ImmutableFunctionCall'
413
532
){
414
533
// Known effects are always propagated upwards
415
534
functionEffects.push(effect);
416
-
}else{
535
+
}elseif(effect.kind==='ContextMutation'){
417
536
/**
418
537
* Contextual effects need to be replayed against the current inference
419
538
* state, which may know more about the value to which the effect applied.
@@ -444,6 +563,8 @@ class InferenceState {
444
563
}// else case 2, local mutable value so this effect was fine
445
564
}
446
565
}
566
+
}else{
567
+
assertExhaustive(effect,`Unexpected function effect kind`);
0 commit comments