Skip to content

Commit da843fd

Browse files
committed
[compiler] Fix for loops in try/catch (#35686)
This is a combination of a) a subagent for investigating compiler errors and b) testing that agent by fixing bugs with for loops within try/catch. My recent diffs to support maybe-throw within value blocks was incomplete and handled many cases, like optionals/logicals/etc within try/catch. However, the handling for for loops was making more assumptions and needed additional fixes. Key changes: * `maybe-throw` terminal `handler` is now nullable. PruneMaybeThrows nulls the handler for blocks that cannot throw, rather than changing to a `goto`. This preserves more information, and makes it easier for BuildReactiveFunction's visitValueBlock() to reconstruct the value blocks * Updates BuildReactiveFunction's handling of `for` init/test/update (and similar for `for..of` and `for..in`) to correctly extract value blocks. The previous logic made assumptions about the shape of the SequenceExpression which were incorrect in some cases within try/catch. The new helper extracts a flattened SequenceExpression. Supporting changes: * The agent itself (tested via this diff) * Updated the script for invoking snap to keep `compiler/` as the working directory, allowing relative paths to work more easily * Add an `--update` (`-u`) flag to `yarn snap minimize`, which updates the fixture in place w the minimized version DiffTrain build for [cd0c487](cd0c487)
1 parent 2e304af commit da843fd

23 files changed

+175
-297
lines changed

compiled-rn/VERSION_NATIVE_FB

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
19.3.0-native-fb-e32c1261-20260203
1+
19.3.0-native-fb-cd0c4879-20260203

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOM-dev.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<c3db5b483d858d21140f24ec4796980c>>
10+
* @generated SignedSource<<5d271ae8502882bfc46f8887357c6c56>>
1111
*/
1212

1313
"use strict";
@@ -410,5 +410,5 @@ __DEV__ &&
410410
exports.useFormStatus = function () {
411411
return resolveDispatcher().useHostTransitionStatus();
412412
};
413-
exports.version = "19.3.0-native-fb-e32c1261-20260203";
413+
exports.version = "19.3.0-native-fb-cd0c4879-20260203";
414414
})();

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOM-prod.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<c2d7eb9e7a15f00e206805bb60e8bfb3>>
10+
* @generated SignedSource<<8b1c96b6c11958e4c20f631ad16a89b7>>
1111
*/
1212

1313
"use strict";
@@ -209,4 +209,4 @@ exports.useFormState = function (action, initialState, permalink) {
209209
exports.useFormStatus = function () {
210210
return ReactSharedInternals.H.useHostTransitionStatus();
211211
};
212-
exports.version = "19.3.0-native-fb-e32c1261-20260203";
212+
exports.version = "19.3.0-native-fb-cd0c4879-20260203";

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOM-profiling.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<c2d7eb9e7a15f00e206805bb60e8bfb3>>
10+
* @generated SignedSource<<8b1c96b6c11958e4c20f631ad16a89b7>>
1111
*/
1212

1313
"use strict";
@@ -209,4 +209,4 @@ exports.useFormState = function (action, initialState, permalink) {
209209
exports.useFormStatus = function () {
210210
return ReactSharedInternals.H.useHostTransitionStatus();
211211
};
212-
exports.version = "19.3.0-native-fb-e32c1261-20260203";
212+
exports.version = "19.3.0-native-fb-cd0c4879-20260203";

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMClient-dev.js

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<09862bfaaadc78bcccb435a1db757bbc>>
10+
* @generated SignedSource<<89d719bcfe2032fda1560e0901121fb9>>
1111
*/
1212

1313
/*
@@ -3923,6 +3923,11 @@ __DEV__ &&
39233923
break;
39243924
}
39253925
}
3926+
function readReactElementTypeof(value) {
3927+
return "$$typeof" in value && hasOwnProperty.call(value, "$$typeof")
3928+
? value.$$typeof
3929+
: void 0;
3930+
}
39263931
function addValueToProperties(
39273932
propertyName,
39283933
value,
@@ -3936,7 +3941,7 @@ __DEV__ &&
39363941
value = "null";
39373942
break;
39383943
} else {
3939-
if (value.$$typeof === REACT_ELEMENT_TYPE) {
3944+
if (readReactElementTypeof(value) === REACT_ELEMENT_TYPE) {
39403945
var typeName = getComponentNameFromType(value.type) || "\u2026",
39413946
key = value.key;
39423947
value = value.props;
@@ -4168,9 +4173,10 @@ __DEV__ &&
41684173
"object" === typeof nextValue &&
41694174
null !== key &&
41704175
null !== nextValue &&
4171-
key.$$typeof === nextValue.$$typeof
4176+
readReactElementTypeof(key) ===
4177+
readReactElementTypeof(nextValue)
41724178
)
4173-
if (nextValue.$$typeof === REACT_ELEMENT_TYPE) {
4179+
if (readReactElementTypeof(nextValue) === REACT_ELEMENT_TYPE) {
41744180
if (
41754181
key.type === nextValue.type &&
41764182
key.key === nextValue.key
@@ -30176,11 +30182,11 @@ __DEV__ &&
3017630182
};
3017730183
(function () {
3017830184
var isomorphicReactPackageVersion = React.version;
30179-
if ("19.3.0-native-fb-e32c1261-20260203" !== isomorphicReactPackageVersion)
30185+
if ("19.3.0-native-fb-cd0c4879-20260203" !== isomorphicReactPackageVersion)
3018030186
throw Error(
3018130187
'Incompatible React versions: The "react" and "react-dom" packages must have the exact same version. Instead got:\n - react: ' +
3018230188
(isomorphicReactPackageVersion +
30183-
"\n - react-dom: 19.3.0-native-fb-e32c1261-20260203\nLearn more: https://react.dev/warnings/version-mismatch")
30189+
"\n - react-dom: 19.3.0-native-fb-cd0c4879-20260203\nLearn more: https://react.dev/warnings/version-mismatch")
3018430190
);
3018530191
})();
3018630192
("function" === typeof Map &&
@@ -30217,10 +30223,10 @@ __DEV__ &&
3021730223
!(function () {
3021830224
var internals = {
3021930225
bundleType: 1,
30220-
version: "19.3.0-native-fb-e32c1261-20260203",
30226+
version: "19.3.0-native-fb-cd0c4879-20260203",
3022130227
rendererPackageName: "react-dom",
3022230228
currentDispatcherRef: ReactSharedInternals,
30223-
reconcilerVersion: "19.3.0-native-fb-e32c1261-20260203"
30229+
reconcilerVersion: "19.3.0-native-fb-cd0c4879-20260203"
3022430230
};
3022530231
internals.overrideHookState = overrideHookState;
3022630232
internals.overrideHookStateDeletePath = overrideHookStateDeletePath;
@@ -30370,5 +30376,5 @@ __DEV__ &&
3037030376
listenToAllSupportedEvents(container);
3037130377
return new ReactDOMHydrationRoot(initialChildren);
3037230378
};
30373-
exports.version = "19.3.0-native-fb-e32c1261-20260203";
30379+
exports.version = "19.3.0-native-fb-cd0c4879-20260203";
3037430380
})();

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMClient-prod.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<0590017e6ae774befd3924f7112cd133>>
10+
* @generated SignedSource<<7c059b020873da9855bf4319ee8130d2>>
1111
*/
1212

1313
/*
@@ -17751,14 +17751,14 @@ ReactDOMHydrationRoot.prototype.unstable_scheduleHydration = function (target) {
1775117751
};
1775217752
var isomorphicReactPackageVersion$jscomp$inline_2045 = React.version;
1775317753
if (
17754-
"19.3.0-native-fb-e32c1261-20260203" !==
17754+
"19.3.0-native-fb-cd0c4879-20260203" !==
1775517755
isomorphicReactPackageVersion$jscomp$inline_2045
1775617756
)
1775717757
throw Error(
1775817758
formatProdErrorMessage(
1775917759
527,
1776017760
isomorphicReactPackageVersion$jscomp$inline_2045,
17761-
"19.3.0-native-fb-e32c1261-20260203"
17761+
"19.3.0-native-fb-cd0c4879-20260203"
1776217762
)
1776317763
);
1776417764
ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
@@ -17780,10 +17780,10 @@ ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
1778017780
};
1778117781
var internals$jscomp$inline_2625 = {
1778217782
bundleType: 0,
17783-
version: "19.3.0-native-fb-e32c1261-20260203",
17783+
version: "19.3.0-native-fb-cd0c4879-20260203",
1778417784
rendererPackageName: "react-dom",
1778517785
currentDispatcherRef: ReactSharedInternals,
17786-
reconcilerVersion: "19.3.0-native-fb-e32c1261-20260203"
17786+
reconcilerVersion: "19.3.0-native-fb-cd0c4879-20260203"
1778717787
};
1778817788
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
1778917789
var hook$jscomp$inline_2626 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
@@ -17890,4 +17890,4 @@ exports.hydrateRoot = function (container, initialChildren, options) {
1789017890
listenToAllSupportedEvents(container);
1789117891
return new ReactDOMHydrationRoot(initialChildren);
1789217892
};
17893-
exports.version = "19.3.0-native-fb-e32c1261-20260203";
17893+
exports.version = "19.3.0-native-fb-cd0c4879-20260203";

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMClient-profiling.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<ee8550c16e45686dc4792365e1a2fa2b>>
10+
* @generated SignedSource<<e053d33fd6d44901c850fc82fe17938c>>
1111
*/
1212

1313
/*
@@ -19740,14 +19740,14 @@ ReactDOMHydrationRoot.prototype.unstable_scheduleHydration = function (target) {
1974019740
};
1974119741
var isomorphicReactPackageVersion$jscomp$inline_2393 = React.version;
1974219742
if (
19743-
"19.3.0-native-fb-e32c1261-20260203" !==
19743+
"19.3.0-native-fb-cd0c4879-20260203" !==
1974419744
isomorphicReactPackageVersion$jscomp$inline_2393
1974519745
)
1974619746
throw Error(
1974719747
formatProdErrorMessage(
1974819748
527,
1974919749
isomorphicReactPackageVersion$jscomp$inline_2393,
19750-
"19.3.0-native-fb-e32c1261-20260203"
19750+
"19.3.0-native-fb-cd0c4879-20260203"
1975119751
)
1975219752
);
1975319753
ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
@@ -19769,10 +19769,10 @@ ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
1976919769
};
1977019770
var internals$jscomp$inline_2400 = {
1977119771
bundleType: 0,
19772-
version: "19.3.0-native-fb-e32c1261-20260203",
19772+
version: "19.3.0-native-fb-cd0c4879-20260203",
1977319773
rendererPackageName: "react-dom",
1977419774
currentDispatcherRef: ReactSharedInternals,
19775-
reconcilerVersion: "19.3.0-native-fb-e32c1261-20260203",
19775+
reconcilerVersion: "19.3.0-native-fb-cd0c4879-20260203",
1977619776
getLaneLabelMap: function () {
1977719777
for (
1977819778
var map = new Map(), lane = 1, index$336 = 0;
@@ -19895,4 +19895,4 @@ exports.hydrateRoot = function (container, initialChildren, options) {
1989519895
listenToAllSupportedEvents(container);
1989619896
return new ReactDOMHydrationRoot(initialChildren);
1989719897
};
19898-
exports.version = "19.3.0-native-fb-e32c1261-20260203";
19898+
exports.version = "19.3.0-native-fb-cd0c4879-20260203";

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMProfiling-dev.js

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<0dfb1aa3fdc5bcf93bfaa12f7eb9fe71>>
10+
* @generated SignedSource<<4149947d453060992fd80341700d854e>>
1111
*/
1212

1313
/*
@@ -3931,6 +3931,11 @@ __DEV__ &&
39313931
break;
39323932
}
39333933
}
3934+
function readReactElementTypeof(value) {
3935+
return "$$typeof" in value && hasOwnProperty.call(value, "$$typeof")
3936+
? value.$$typeof
3937+
: void 0;
3938+
}
39343939
function addValueToProperties(
39353940
propertyName,
39363941
value,
@@ -3944,7 +3949,7 @@ __DEV__ &&
39443949
value = "null";
39453950
break;
39463951
} else {
3947-
if (value.$$typeof === REACT_ELEMENT_TYPE) {
3952+
if (readReactElementTypeof(value) === REACT_ELEMENT_TYPE) {
39483953
var typeName = getComponentNameFromType(value.type) || "\u2026",
39493954
key = value.key;
39503955
value = value.props;
@@ -4176,9 +4181,10 @@ __DEV__ &&
41764181
"object" === typeof nextValue &&
41774182
null !== key &&
41784183
null !== nextValue &&
4179-
key.$$typeof === nextValue.$$typeof
4184+
readReactElementTypeof(key) ===
4185+
readReactElementTypeof(nextValue)
41804186
)
4181-
if (nextValue.$$typeof === REACT_ELEMENT_TYPE) {
4187+
if (readReactElementTypeof(nextValue) === REACT_ELEMENT_TYPE) {
41824188
if (
41834189
key.type === nextValue.type &&
41844190
key.key === nextValue.key
@@ -30238,11 +30244,11 @@ __DEV__ &&
3023830244
};
3023930245
(function () {
3024030246
var isomorphicReactPackageVersion = React.version;
30241-
if ("19.3.0-native-fb-e32c1261-20260203" !== isomorphicReactPackageVersion)
30247+
if ("19.3.0-native-fb-cd0c4879-20260203" !== isomorphicReactPackageVersion)
3024230248
throw Error(
3024330249
'Incompatible React versions: The "react" and "react-dom" packages must have the exact same version. Instead got:\n - react: ' +
3024430250
(isomorphicReactPackageVersion +
30245-
"\n - react-dom: 19.3.0-native-fb-e32c1261-20260203\nLearn more: https://react.dev/warnings/version-mismatch")
30251+
"\n - react-dom: 19.3.0-native-fb-cd0c4879-20260203\nLearn more: https://react.dev/warnings/version-mismatch")
3024630252
);
3024730253
})();
3024830254
("function" === typeof Map &&
@@ -30279,10 +30285,10 @@ __DEV__ &&
3027930285
!(function () {
3028030286
var internals = {
3028130287
bundleType: 1,
30282-
version: "19.3.0-native-fb-e32c1261-20260203",
30288+
version: "19.3.0-native-fb-cd0c4879-20260203",
3028330289
rendererPackageName: "react-dom",
3028430290
currentDispatcherRef: ReactSharedInternals,
30285-
reconcilerVersion: "19.3.0-native-fb-e32c1261-20260203"
30291+
reconcilerVersion: "19.3.0-native-fb-cd0c4879-20260203"
3028630292
};
3028730293
internals.overrideHookState = overrideHookState;
3028830294
internals.overrideHookStateDeletePath = overrideHookStateDeletePath;
@@ -30748,7 +30754,7 @@ __DEV__ &&
3074830754
exports.useFormStatus = function () {
3074930755
return resolveDispatcher().useHostTransitionStatus();
3075030756
};
30751-
exports.version = "19.3.0-native-fb-e32c1261-20260203";
30757+
exports.version = "19.3.0-native-fb-cd0c4879-20260203";
3075230758
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
3075330759
"function" ===
3075430760
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMProfiling-prod.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<5d4690adf75aa69c1270652ac48bc2bc>>
10+
* @generated SignedSource<<93cd955dc8eb51f9afe1e477727226ed>>
1111
*/
1212

1313
/*
@@ -17768,14 +17768,14 @@ ReactDOMHydrationRoot.prototype.unstable_scheduleHydration = function (target) {
1776817768
};
1776917769
var isomorphicReactPackageVersion$jscomp$inline_2046 = React.version;
1777017770
if (
17771-
"19.3.0-native-fb-e32c1261-20260203" !==
17771+
"19.3.0-native-fb-cd0c4879-20260203" !==
1777217772
isomorphicReactPackageVersion$jscomp$inline_2046
1777317773
)
1777417774
throw Error(
1777517775
formatProdErrorMessage(
1777617776
527,
1777717777
isomorphicReactPackageVersion$jscomp$inline_2046,
17778-
"19.3.0-native-fb-e32c1261-20260203"
17778+
"19.3.0-native-fb-cd0c4879-20260203"
1777917779
)
1778017780
);
1778117781
ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
@@ -17797,10 +17797,10 @@ ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
1779717797
};
1779817798
var internals$jscomp$inline_2628 = {
1779917799
bundleType: 0,
17800-
version: "19.3.0-native-fb-e32c1261-20260203",
17800+
version: "19.3.0-native-fb-cd0c4879-20260203",
1780117801
rendererPackageName: "react-dom",
1780217802
currentDispatcherRef: ReactSharedInternals,
17803-
reconcilerVersion: "19.3.0-native-fb-e32c1261-20260203"
17803+
reconcilerVersion: "19.3.0-native-fb-cd0c4879-20260203"
1780417804
};
1780517805
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
1780617806
var hook$jscomp$inline_2629 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
@@ -18060,4 +18060,4 @@ exports.useFormState = function (action, initialState, permalink) {
1806018060
exports.useFormStatus = function () {
1806118061
return ReactSharedInternals.H.useHostTransitionStatus();
1806218062
};
18063-
exports.version = "19.3.0-native-fb-e32c1261-20260203";
18063+
exports.version = "19.3.0-native-fb-cd0c4879-20260203";

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMProfiling-profiling.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<8caef8b2138d2cdbe5dd73df635f76da>>
10+
* @generated SignedSource<<9af1d665fd54d49606fea04644d192e6>>
1111
*/
1212

1313
/*
@@ -19761,14 +19761,14 @@ ReactDOMHydrationRoot.prototype.unstable_scheduleHydration = function (target) {
1976119761
};
1976219762
var isomorphicReactPackageVersion$jscomp$inline_2394 = React.version;
1976319763
if (
19764-
"19.3.0-native-fb-e32c1261-20260203" !==
19764+
"19.3.0-native-fb-cd0c4879-20260203" !==
1976519765
isomorphicReactPackageVersion$jscomp$inline_2394
1976619766
)
1976719767
throw Error(
1976819768
formatProdErrorMessage(
1976919769
527,
1977019770
isomorphicReactPackageVersion$jscomp$inline_2394,
19771-
"19.3.0-native-fb-e32c1261-20260203"
19771+
"19.3.0-native-fb-cd0c4879-20260203"
1977219772
)
1977319773
);
1977419774
ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
@@ -19790,10 +19790,10 @@ ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
1979019790
};
1979119791
var internals$jscomp$inline_2401 = {
1979219792
bundleType: 0,
19793-
version: "19.3.0-native-fb-e32c1261-20260203",
19793+
version: "19.3.0-native-fb-cd0c4879-20260203",
1979419794
rendererPackageName: "react-dom",
1979519795
currentDispatcherRef: ReactSharedInternals,
19796-
reconcilerVersion: "19.3.0-native-fb-e32c1261-20260203",
19796+
reconcilerVersion: "19.3.0-native-fb-cd0c4879-20260203",
1979719797
getLaneLabelMap: function () {
1979819798
for (
1979919799
var map = new Map(), lane = 1, index$336 = 0;
@@ -20069,7 +20069,7 @@ exports.useFormState = function (action, initialState, permalink) {
2006920069
exports.useFormStatus = function () {
2007020070
return ReactSharedInternals.H.useHostTransitionStatus();
2007120071
};
20072-
exports.version = "19.3.0-native-fb-e32c1261-20260203";
20072+
exports.version = "19.3.0-native-fb-cd0c4879-20260203";
2007320073
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
2007420074
"function" ===
2007520075
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

0 commit comments

Comments
 (0)