@samitouri / QOS-React / commits / edbb6e2bdb

Test case for Array.push on frozen array

Just making sure that we reject this

Joe Savona committed May 25, 2023 at 16:00 UTC edbb6e2bdb6ac423c8165a3fa3c3e3d2aab07ea1
2 files changed +27
compiler/forget/src/__tests__/fixtures/compiler/error.invalid-array-push-frozen.expect.md new
+21
@@ -0,0 +1,21 @@
1 +
2 +## Input
3 +
4 +```javascript
5 +function Component(props) {
6 + const x = [];
7 + <div>{x}</div>;
8 + x.push(props.value);
9 + return x;
10 +}
11 +
12 +```
13 +
14 +
15 +## Error
16 +
17 +```
18 +[ReactForget] InvalidInput: InferReferenceEffects: inferred mutation of known immutable value. Found mutation of $20:TObject<BuiltInArray> (frozen) (4:4)
19 +```
20 +
21 +
\ No newline at end of file
compiler/forget/src/__tests__/fixtures/compiler/error.invalid-array-push-frozen.js new
+6
@@ -0,0 +1,6 @@
1 +function Component(props) {
2 + const x = [];
3 + <div>{x}</div>;
4 + x.push(props.value);
5 + return x;
6 +}