@samitouri / QOS-React / commits / 1cf8d9bc8b

Repro for missing predecessor with try/catch

Found when running the compiler on a large swath of internal code. PruneMaybeThrows rewrites terminals, but the logic to update subsequent phis was incorrectly dropping phis rather than rewriting them. Fixed in the next PR.

Joe Savona committed Mar 20, 2024 at 14:07 UTC 1cf8d9bc8b8ce905ce55043707fffb0b0c504e4f
2 files changed +41
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.repro-preds-undefined.expect.md new
+28
@@ -0,0 +1,28 @@
1 +
2 +## Input
3 +
4 +```javascript
5 +// @enableAssumeHooksFollowRulesOfReact @enableTransitivelyFreezeFunctionExpressions
6 +function useSupportsTouchEvent() {
7 + return useMemo(() => {
8 + if (checkforTouchEvents) {
9 + try {
10 + document.createEvent("TouchEvent");
11 + return true;
12 + } catch {
13 + return false;
14 + }
15 + }
16 + }, []);
17 +}
18 +
19 +```
20 +
21 +
22 +## Error
23 +
24 +```
25 +Cannot read properties of undefined (reading 'preds')
26 +```
27 +
28 +
\ No newline at end of file
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.repro-preds-undefined.js new
+13
@@ -0,0 +1,13 @@
1 +// @enableAssumeHooksFollowRulesOfReact @enableTransitivelyFreezeFunctionExpressions
2 +function useSupportsTouchEvent() {
3 + return useMemo(() => {
4 + if (checkforTouchEvents) {
5 + try {
6 + document.createEvent("TouchEvent");
7 + return true;
8 + } catch {
9 + return false;
10 + }
11 + }
12 + }, []);
13 +}