Skip to content

[compiler] Correctly infer context mutation places as outer (context) places #33114

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 38 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
e9b19a6
[compiler] Correctly infer context mutation places as outer (context)…
josephsavona May 3, 2025
3d646a8
Update on "[compiler] Correctly infer context mutation places as oute…
josephsavona May 8, 2025
e5a4c87
Update on "[compiler] Correctly infer context mutation places as oute…
josephsavona May 8, 2025
3f81334
Update on "[compiler] Correctly infer context mutation places as oute…
josephsavona May 8, 2025
0a366ed
Update on "[compiler] Correctly infer context mutation places as oute…
josephsavona May 8, 2025
3c7ed29
Update on "[compiler] Correctly infer context mutation places as oute…
josephsavona May 9, 2025
601c904
Update on "[compiler] Correctly infer context mutation places as oute…
josephsavona May 9, 2025
b32b3b8
Update on "[compiler] Correctly infer context mutation places as oute…
josephsavona May 9, 2025
c2c343e
Update on "[compiler] Correctly infer context mutation places as oute…
josephsavona May 9, 2025
fbe597d
Update on "[compiler] Correctly infer context mutation places as oute…
josephsavona May 9, 2025
3c0908a
Update on "[compiler] Correctly infer context mutation places as oute…
josephsavona May 12, 2025
dd775b1
Update on "[compiler] Correctly infer context mutation places as oute…
josephsavona May 13, 2025
f8a5791
Update on "[compiler] Correctly infer context mutation places as oute…
josephsavona May 22, 2025
9fdc56a
Update on "[compiler] Correctly infer context mutation places as oute…
josephsavona May 23, 2025
605f281
Update on "[compiler] Correctly infer context mutation places as oute…
josephsavona May 27, 2025
ab4a46b
Update on "[compiler] Correctly infer context mutation places as oute…
josephsavona May 27, 2025
b19fe0e
Update on "[compiler] Correctly infer context mutation places as oute…
josephsavona May 28, 2025
6a6d605
Update on "[compiler] Correctly infer context mutation places as oute…
josephsavona May 28, 2025
1b80bcb
Update on "[compiler] Correctly infer context mutation places as oute…
josephsavona May 29, 2025
f6f78d5
Update on "[compiler] Correctly infer context mutation places as oute…
josephsavona May 29, 2025
ad14000
Update on "[compiler] Correctly infer context mutation places as oute…
josephsavona May 30, 2025
56b0d6b
Update on "[compiler] Correctly infer context mutation places as oute…
josephsavona May 30, 2025
fc15ba3
Update on "[compiler] Correctly infer context mutation places as oute…
josephsavona May 30, 2025
11da0b8
Update on "[compiler] Correctly infer context mutation places as oute…
josephsavona May 30, 2025
9574710
Update on "[compiler] Correctly infer context mutation places as oute…
josephsavona Jun 2, 2025
1fc953c
Update on "[compiler] Correctly infer context mutation places as oute…
josephsavona Jun 3, 2025
2ebef2d
Update on "[compiler] Correctly infer context mutation places as oute…
josephsavona Jun 3, 2025
b6f152d
Update on "[compiler] Correctly infer context mutation places as oute…
josephsavona Jun 3, 2025
2614b99
Update on "[compiler] Correctly infer context mutation places as oute…
josephsavona Jun 4, 2025
214d186
Update on "[compiler] Correctly infer context mutation places as oute…
josephsavona Jun 4, 2025
1649769
Update on "[compiler] Correctly infer context mutation places as oute…
josephsavona Jun 5, 2025
62c6a44
Update on "[compiler] Correctly infer context mutation places as oute…
josephsavona Jun 5, 2025
8fa4547
Update on "[compiler] Correctly infer context mutation places as oute…
josephsavona Jun 6, 2025
f103712
Update on "[compiler] Correctly infer context mutation places as oute…
josephsavona Jun 6, 2025
fc49042
Update on "[compiler] Correctly infer context mutation places as oute…
josephsavona Jun 6, 2025
d2bd991
Update on "[compiler] Correctly infer context mutation places as oute…
josephsavona Jun 6, 2025
cdbf889
Update on "[compiler] Correctly infer context mutation places as oute…
josephsavona Jun 7, 2025
85f82fe
Update on "[compiler] Correctly infer context mutation places as oute…
josephsavona Jun 9, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import {
import {FunctionSignature} from '../HIR/ObjectShape';
import {
printIdentifier,
printMixedHIR,
printInstructionValue,
printPlace,
printSourceLocation,
} from '../HIR/PrintHIR';
Expand Down Expand Up @@ -669,7 +669,14 @@ class InferenceState {
}
for (const [value, kind] of this.#values) {
const id = identify(value);
result.values[id] = {kind, value: printMixedHIR(value)};
result.values[id] = {
abstract: {
kind: kind.kind,
context: [...kind.context].map(printPlace),
reason: [...kind.reason],
},
value: printInstructionValue(value),
};
}
for (const [variable, values] of this.#variables) {
result.variables[`$${variable}`] = [...values].map(identify);
Expand Down Expand Up @@ -1844,11 +1851,11 @@ function getContextRefOperand(
): Array<Place> {
const result = [];
for (const place of eachInstructionValueOperand(instrValue)) {
if (
state.isDefined(place) &&
state.kind(place).kind === ValueKind.Context
) {
result.push(place);
if (state.isDefined(place)) {
const kind = state.kind(place);
if (kind.kind === ValueKind.Context) {
result.push(...kind.context);
}
}
}
return result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,23 +36,13 @@ function Component() {
## Error

```
18 | );
19 | const ref = useRef(null);
> 20 | useEffect(() => {
| ^^^^^^^
> 21 | if (ref.current === null) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> 22 | update();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> 23 | }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> 24 | }, [update]);
| ^^^^ InvalidReact: This argument is a function which modifies local variables when called, which can bypass memoization and cause the UI not to update. Functions that are returned from hooks, passed as arguments to hooks, or passed as props to components may not mutate local variables (20:24)

InvalidReact: The function modifies a local variable here (14:14)
25 |
26 | return 'ok';
27 | }
12 | ...partialParams,
13 | };
> 14 | nextParams.param = 'value';
| ^^^^^^^^^^ InvalidReact: Mutating a value returned from a function whose return value should not be mutated. Found mutation of `params` (14:14)
15 | console.log(nextParams);
16 | },
17 | [params]
```


Loading