From 73fa712108dcd7b1a103291650087f561be613b4 Mon Sep 17 00:00:00 2001 From: Joe Savona Date: Fri, 22 Mar 2024 14:32:47 -0700 Subject: [PATCH] Repro for destructuring with partial context variables --- ...incompatible-destructuring-kinds.expect.md | 35 +++++++++++++++++++ ...r.todo-incompatible-destructuring-kinds.js | 14 ++++++++ 2 files changed, 49 insertions(+) create mode 100644 compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.todo-incompatible-destructuring-kinds.expect.md create mode 100644 compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.todo-incompatible-destructuring-kinds.js diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.todo-incompatible-destructuring-kinds.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.todo-incompatible-destructuring-kinds.expect.md new file mode 100644 index 0000000000..cd038eff52 --- /dev/null +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.todo-incompatible-destructuring-kinds.expect.md @@ -0,0 +1,35 @@ + +## Input + +```javascript +import { useMemo } from "react"; +import { Stringify } from "shared-runtime"; + +function Component({}) { + let a = "a"; + let b = ""; + [a, b] = [null, null]; + return a} />; +} + +export const FIXTURE_ENTRYPOINT = { + fn: Component, + params: [{}], +}; + +``` + + +## Error + +``` + 5 | let a = "a"; + 6 | let b = ""; +> 7 | [a, b] = [null, null]; + | ^ [ReactForget] Invariant: Expected consistent kind for destructuring. Other places were 'Const' but 'store b$36[10:12]' is reassigned (7:7) + 8 | return a} />; + 9 | } + 10 | +``` + + \ No newline at end of file diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.todo-incompatible-destructuring-kinds.js b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.todo-incompatible-destructuring-kinds.js new file mode 100644 index 0000000000..80ec7e3526 --- /dev/null +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.todo-incompatible-destructuring-kinds.js @@ -0,0 +1,14 @@ +import { useMemo } from "react"; +import { Stringify } from "shared-runtime"; + +function Component({}) { + let a = "a"; + let b = ""; + [a, b] = [null, null]; + return a} />; +} + +export const FIXTURE_ENTRYPOINT = { + fn: Component, + params: [{}], +};