From edbb6e2bdb6ac423c8165a3fa3c3e3d2aab07ea1 Mon Sep 17 00:00:00 2001 From: Joe Savona Date: Thu, 25 May 2023 16:00:35 -0700 Subject: [PATCH] Test case for Array.push on frozen array Just making sure that we reject this --- .../error.invalid-array-push-frozen.expect.md | 21 +++++++++++++++++++ .../error.invalid-array-push-frozen.js | 6 ++++++ 2 files changed, 27 insertions(+) create mode 100644 compiler/forget/src/__tests__/fixtures/compiler/error.invalid-array-push-frozen.expect.md create mode 100644 compiler/forget/src/__tests__/fixtures/compiler/error.invalid-array-push-frozen.js diff --git a/compiler/forget/src/__tests__/fixtures/compiler/error.invalid-array-push-frozen.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/error.invalid-array-push-frozen.expect.md new file mode 100644 index 0000000000..0c52830e06 --- /dev/null +++ b/compiler/forget/src/__tests__/fixtures/compiler/error.invalid-array-push-frozen.expect.md @@ -0,0 +1,21 @@ + +## Input + +```javascript +function Component(props) { + const x = []; +
{x}
; + x.push(props.value); + return x; +} + +``` + + +## Error + +``` +[ReactForget] InvalidInput: InferReferenceEffects: inferred mutation of known immutable value. Found mutation of $20:TObject (frozen) (4:4) +``` + + \ No newline at end of file diff --git a/compiler/forget/src/__tests__/fixtures/compiler/error.invalid-array-push-frozen.js b/compiler/forget/src/__tests__/fixtures/compiler/error.invalid-array-push-frozen.js new file mode 100644 index 0000000000..3ede9c0463 --- /dev/null +++ b/compiler/forget/src/__tests__/fixtures/compiler/error.invalid-array-push-frozen.js @@ -0,0 +1,6 @@ +function Component(props) { + const x = []; +
{x}
; + x.push(props.value); + return x; +}