mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
[repro] Fixture for incorrect lowering for break (label within loop)
--- unlabeled breaks must goto the nearest iteration or switch boundary (not labeled block) --- Sprout fails with the following: ``` FAIL: bug-unlabeled-break-within-label-loop >> Unexpected error during test: Found differences in evaluator results Non-forget (expected): (kind: ok) ["0 @A","0 @B","0 @C","1 @A"] Forget: (kind: ok) ["0 @A","0 @B","0 @C","1 @A","1 @C"] ```
This commit is contained in:
+62
@@ -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],
|
||||
};
|
||||
|
||||
```
|
||||
|
||||
+19
@@ -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],
|
||||
};
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user