diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/bug-unlabeled-break-within-label-loop.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/bug-unlabeled-break-within-label-loop.expect.md new file mode 100644 index 0000000000..8348b32036 --- /dev/null +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/bug-unlabeled-break-within-label-loop.expect.md @@ -0,0 +1,62 @@ + +## Input + +```javascript +function useHook(end) { + const log = []; + for (let i = 0; i < end + 1; i++) { + log.push(`${i} @A`); + bb0: { + if (i === end) { + break; + } + log.push(`${i} @B`); + } + log.push(`${i} @C`); + } + return log; +} + +export const FIXTURE_ENTRYPOINT = { + fn: useHook, + params: [1], +}; + +``` + +## Code + +```javascript +import { unstable_useMemoCache as useMemoCache } from "react"; +function useHook(end) { + const $ = useMemoCache(2); + let log; + if ($[0] !== end) { + log = []; + for (let i = 0; i < end + 1; i++) { + log.push(`${i} @A`); + bb6: { + if (i === end) { + break bb6; + } + + log.push(`${i} @B`); + } + + log.push(`${i} @C`); + } + $[0] = end; + $[1] = log; + } else { + log = $[1]; + } + return log; +} + +export const FIXTURE_ENTRYPOINT = { + fn: useHook, + params: [1], +}; + +``` + \ No newline at end of file diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/bug-unlabeled-break-within-label-loop.ts b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/bug-unlabeled-break-within-label-loop.ts new file mode 100644 index 0000000000..9d3ac383b9 --- /dev/null +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/bug-unlabeled-break-within-label-loop.ts @@ -0,0 +1,19 @@ +function useHook(end) { + const log = []; + for (let i = 0; i < end + 1; i++) { + log.push(`${i} @A`); + bb0: { + if (i === end) { + break; + } + log.push(`${i} @B`); + } + log.push(`${i} @C`); + } + return log; +} + +export const FIXTURE_ENTRYPOINT = { + fn: useHook, + params: [1], +}; diff --git a/compiler/packages/snap/src/SproutTodoFilter.ts b/compiler/packages/snap/src/SproutTodoFilter.ts index fef339c363..f956fe10bf 100644 --- a/compiler/packages/snap/src/SproutTodoFilter.ts +++ b/compiler/packages/snap/src/SproutTodoFilter.ts @@ -534,6 +534,7 @@ const skipFilter = new Set([ // bugs "bug-reduce-reactive-deps-return-in-scope", "bug-reduce-reactive-deps-break-in-scope", + "bug-unlabeled-break-within-label-loop", // 'react-forget-runtime' not yet supported "flag-enable-emit-hook-guards",