[compiler][bugfix] Bail out when a memo block declares hoisted fns (#32765)

Note that bailing out adds false positives for hoisted functions whose
only references are within other functions. For example, this rewrite
would be safe.
```js
// source program
  function foo() {
    return bar();
  }
  function bar() {
    return 42;
  }

// compiler output
let bar;
if (/* deps changed */) {
  function foo() {
    return bar();
  }
  bar = function bar() {
    return 42;
  }
}
```
These false positives are difficult to detect because any maybe-call of
foo before the definition of bar would be invalid.

Instead of bailing out, we should rewrite hoisted function declarations
to the following form.
```js
let bar$0;
if (/* deps changed */) {
  // All references within the declaring memo block
  // or before the function declaration should use
  // the original identifier `bar`
  function foo() {
    return bar();
  }
  function bar() {
    return 42;
  }
  bar$0 = bar;
}
// All references after the declaring memo block
// or after the function declaration should use
// the rewritten declaration `bar$0`
```

DiffTrain build for [0c1575cee8](https://github.com/facebook/react/commit/0c1575cee8a78dd097edcafc307522ad000e372c)
This commit is contained in:
mofeiZ
2025-05-05 08:52:26 -07:00
parent d45b272868
commit 45b4735773
26 changed files with 183 additions and 93 deletions
+1 -1
View File
@@ -1 +1 @@
19.2.0-native-fb-3ec88e79-20250505
19.2.0-native-fb-0c1575ce-20250505
@@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<1c9b2192c6ad951c0c453a1c800f767e>>
* @generated SignedSource<<dd97c826f632d7f1a7acc8865f6a8a69>>
*/
"use strict";
@@ -404,5 +404,5 @@ __DEV__ &&
exports.useFormStatus = function () {
return resolveDispatcher().useHostTransitionStatus();
};
exports.version = "19.2.0-native-fb-3ec88e79-20250505";
exports.version = "19.2.0-native-fb-0c1575ce-20250505";
})();
@@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<29c435e758f7d5c9e0f833879894cda1>>
* @generated SignedSource<<208e82f9a1794918db4aa186a5aaff05>>
*/
"use strict";
@@ -203,4 +203,4 @@ exports.useFormState = function (action, initialState, permalink) {
exports.useFormStatus = function () {
return ReactSharedInternals.H.useHostTransitionStatus();
};
exports.version = "19.2.0-native-fb-3ec88e79-20250505";
exports.version = "19.2.0-native-fb-0c1575ce-20250505";
@@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<29c435e758f7d5c9e0f833879894cda1>>
* @generated SignedSource<<208e82f9a1794918db4aa186a5aaff05>>
*/
"use strict";
@@ -203,4 +203,4 @@ exports.useFormState = function (action, initialState, permalink) {
exports.useFormStatus = function () {
return ReactSharedInternals.H.useHostTransitionStatus();
};
exports.version = "19.2.0-native-fb-3ec88e79-20250505";
exports.version = "19.2.0-native-fb-0c1575ce-20250505";
@@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<e9c230b6bd3144963372e8d3763393e6>>
* @generated SignedSource<<09a114943918e527cc3e66abe5cc225f>>
*/
/*
@@ -26650,11 +26650,11 @@ __DEV__ &&
};
(function () {
var isomorphicReactPackageVersion = React.version;
if ("19.2.0-native-fb-3ec88e79-20250505" !== isomorphicReactPackageVersion)
if ("19.2.0-native-fb-0c1575ce-20250505" !== isomorphicReactPackageVersion)
throw Error(
'Incompatible React versions: The "react" and "react-dom" packages must have the exact same version. Instead got:\n - react: ' +
(isomorphicReactPackageVersion +
"\n - react-dom: 19.2.0-native-fb-3ec88e79-20250505\nLearn more: https://react.dev/warnings/version-mismatch")
"\n - react-dom: 19.2.0-native-fb-0c1575ce-20250505\nLearn more: https://react.dev/warnings/version-mismatch")
);
})();
("function" === typeof Map &&
@@ -26691,10 +26691,10 @@ __DEV__ &&
!(function () {
var internals = {
bundleType: 1,
version: "19.2.0-native-fb-3ec88e79-20250505",
version: "19.2.0-native-fb-0c1575ce-20250505",
rendererPackageName: "react-dom",
currentDispatcherRef: ReactSharedInternals,
reconcilerVersion: "19.2.0-native-fb-3ec88e79-20250505"
reconcilerVersion: "19.2.0-native-fb-0c1575ce-20250505"
};
internals.overrideHookState = overrideHookState;
internals.overrideHookStateDeletePath = overrideHookStateDeletePath;
@@ -26838,5 +26838,5 @@ __DEV__ &&
listenToAllSupportedEvents(container);
return new ReactDOMHydrationRoot(initialChildren);
};
exports.version = "19.2.0-native-fb-3ec88e79-20250505";
exports.version = "19.2.0-native-fb-0c1575ce-20250505";
})();
@@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<7a50b7821bd51921ccacb330ca49a0fe>>
* @generated SignedSource<<b26db787df52c5c331ffb45adc71bf5c>>
*/
/*
@@ -16748,14 +16748,14 @@ ReactDOMHydrationRoot.prototype.unstable_scheduleHydration = function (target) {
};
var isomorphicReactPackageVersion$jscomp$inline_1904 = React.version;
if (
"19.2.0-native-fb-3ec88e79-20250505" !==
"19.2.0-native-fb-0c1575ce-20250505" !==
isomorphicReactPackageVersion$jscomp$inline_1904
)
throw Error(
formatProdErrorMessage(
527,
isomorphicReactPackageVersion$jscomp$inline_1904,
"19.2.0-native-fb-3ec88e79-20250505"
"19.2.0-native-fb-0c1575ce-20250505"
)
);
ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
@@ -16777,10 +16777,10 @@ ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
};
var internals$jscomp$inline_2388 = {
bundleType: 0,
version: "19.2.0-native-fb-3ec88e79-20250505",
version: "19.2.0-native-fb-0c1575ce-20250505",
rendererPackageName: "react-dom",
currentDispatcherRef: ReactSharedInternals,
reconcilerVersion: "19.2.0-native-fb-3ec88e79-20250505"
reconcilerVersion: "19.2.0-native-fb-0c1575ce-20250505"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_2389 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
@@ -16884,4 +16884,4 @@ exports.hydrateRoot = function (container, initialChildren, options) {
listenToAllSupportedEvents(container);
return new ReactDOMHydrationRoot(initialChildren);
};
exports.version = "19.2.0-native-fb-3ec88e79-20250505";
exports.version = "19.2.0-native-fb-0c1575ce-20250505";
@@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<dc97ed18c4b41fb35e545722bbd34157>>
* @generated SignedSource<<eac96426867e3a67b1dc4fa7c92413a3>>
*/
/*
@@ -17457,14 +17457,14 @@ ReactDOMHydrationRoot.prototype.unstable_scheduleHydration = function (target) {
};
var isomorphicReactPackageVersion$jscomp$inline_2007 = React.version;
if (
"19.2.0-native-fb-3ec88e79-20250505" !==
"19.2.0-native-fb-0c1575ce-20250505" !==
isomorphicReactPackageVersion$jscomp$inline_2007
)
throw Error(
formatProdErrorMessage(
527,
isomorphicReactPackageVersion$jscomp$inline_2007,
"19.2.0-native-fb-3ec88e79-20250505"
"19.2.0-native-fb-0c1575ce-20250505"
)
);
ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
@@ -17486,10 +17486,10 @@ ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
};
var internals$jscomp$inline_2014 = {
bundleType: 0,
version: "19.2.0-native-fb-3ec88e79-20250505",
version: "19.2.0-native-fb-0c1575ce-20250505",
rendererPackageName: "react-dom",
currentDispatcherRef: ReactSharedInternals,
reconcilerVersion: "19.2.0-native-fb-3ec88e79-20250505",
reconcilerVersion: "19.2.0-native-fb-0c1575ce-20250505",
getLaneLabelMap: function () {
for (
var map = new Map(), lane = 1, index$305 = 0;
@@ -17608,4 +17608,4 @@ exports.hydrateRoot = function (container, initialChildren, options) {
listenToAllSupportedEvents(container);
return new ReactDOMHydrationRoot(initialChildren);
};
exports.version = "19.2.0-native-fb-3ec88e79-20250505";
exports.version = "19.2.0-native-fb-0c1575ce-20250505";
@@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<e0885841fb560eafd6e9a1806a6ad0a2>>
* @generated SignedSource<<987c435d52234163e341416034e105c5>>
*/
/*
@@ -26711,11 +26711,11 @@ __DEV__ &&
};
(function () {
var isomorphicReactPackageVersion = React.version;
if ("19.2.0-native-fb-3ec88e79-20250505" !== isomorphicReactPackageVersion)
if ("19.2.0-native-fb-0c1575ce-20250505" !== isomorphicReactPackageVersion)
throw Error(
'Incompatible React versions: The "react" and "react-dom" packages must have the exact same version. Instead got:\n - react: ' +
(isomorphicReactPackageVersion +
"\n - react-dom: 19.2.0-native-fb-3ec88e79-20250505\nLearn more: https://react.dev/warnings/version-mismatch")
"\n - react-dom: 19.2.0-native-fb-0c1575ce-20250505\nLearn more: https://react.dev/warnings/version-mismatch")
);
})();
("function" === typeof Map &&
@@ -26752,10 +26752,10 @@ __DEV__ &&
!(function () {
var internals = {
bundleType: 1,
version: "19.2.0-native-fb-3ec88e79-20250505",
version: "19.2.0-native-fb-0c1575ce-20250505",
rendererPackageName: "react-dom",
currentDispatcherRef: ReactSharedInternals,
reconcilerVersion: "19.2.0-native-fb-3ec88e79-20250505"
reconcilerVersion: "19.2.0-native-fb-0c1575ce-20250505"
};
internals.overrideHookState = overrideHookState;
internals.overrideHookStateDeletePath = overrideHookStateDeletePath;
@@ -27215,7 +27215,7 @@ __DEV__ &&
exports.useFormStatus = function () {
return resolveDispatcher().useHostTransitionStatus();
};
exports.version = "19.2.0-native-fb-3ec88e79-20250505";
exports.version = "19.2.0-native-fb-0c1575ce-20250505";
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
"function" ===
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&
@@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<93d5be7ebf9c105b11e917914505bef9>>
* @generated SignedSource<<7460ce65cefe3b9403e401833aaf517f>>
*/
/*
@@ -16759,14 +16759,14 @@ ReactDOMHydrationRoot.prototype.unstable_scheduleHydration = function (target) {
};
var isomorphicReactPackageVersion$jscomp$inline_1905 = React.version;
if (
"19.2.0-native-fb-3ec88e79-20250505" !==
"19.2.0-native-fb-0c1575ce-20250505" !==
isomorphicReactPackageVersion$jscomp$inline_1905
)
throw Error(
formatProdErrorMessage(
527,
isomorphicReactPackageVersion$jscomp$inline_1905,
"19.2.0-native-fb-3ec88e79-20250505"
"19.2.0-native-fb-0c1575ce-20250505"
)
);
ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
@@ -16788,10 +16788,10 @@ ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
};
var internals$jscomp$inline_2391 = {
bundleType: 0,
version: "19.2.0-native-fb-3ec88e79-20250505",
version: "19.2.0-native-fb-0c1575ce-20250505",
rendererPackageName: "react-dom",
currentDispatcherRef: ReactSharedInternals,
reconcilerVersion: "19.2.0-native-fb-3ec88e79-20250505"
reconcilerVersion: "19.2.0-native-fb-0c1575ce-20250505"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_2392 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
@@ -17049,4 +17049,4 @@ exports.useFormState = function (action, initialState, permalink) {
exports.useFormStatus = function () {
return ReactSharedInternals.H.useHostTransitionStatus();
};
exports.version = "19.2.0-native-fb-3ec88e79-20250505";
exports.version = "19.2.0-native-fb-0c1575ce-20250505";
@@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<0eeb759e7bc62377bc794462ee0aee69>>
* @generated SignedSource<<dd654c7e3b8ba8719e848a6ae65e12a5>>
*/
/*
@@ -17472,14 +17472,14 @@ ReactDOMHydrationRoot.prototype.unstable_scheduleHydration = function (target) {
};
var isomorphicReactPackageVersion$jscomp$inline_2008 = React.version;
if (
"19.2.0-native-fb-3ec88e79-20250505" !==
"19.2.0-native-fb-0c1575ce-20250505" !==
isomorphicReactPackageVersion$jscomp$inline_2008
)
throw Error(
formatProdErrorMessage(
527,
isomorphicReactPackageVersion$jscomp$inline_2008,
"19.2.0-native-fb-3ec88e79-20250505"
"19.2.0-native-fb-0c1575ce-20250505"
)
);
ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
@@ -17501,10 +17501,10 @@ ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
};
var internals$jscomp$inline_2015 = {
bundleType: 0,
version: "19.2.0-native-fb-3ec88e79-20250505",
version: "19.2.0-native-fb-0c1575ce-20250505",
rendererPackageName: "react-dom",
currentDispatcherRef: ReactSharedInternals,
reconcilerVersion: "19.2.0-native-fb-3ec88e79-20250505",
reconcilerVersion: "19.2.0-native-fb-0c1575ce-20250505",
getLaneLabelMap: function () {
for (
var map = new Map(), lane = 1, index$305 = 0;
@@ -17777,7 +17777,7 @@ exports.useFormState = function (action, initialState, permalink) {
exports.useFormStatus = function () {
return ReactSharedInternals.H.useHostTransitionStatus();
};
exports.version = "19.2.0-native-fb-3ec88e79-20250505";
exports.version = "19.2.0-native-fb-0c1575ce-20250505";
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
"function" ===
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&
@@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<3c6d2f14703d6a109a6a1d7984679413>>
* @generated SignedSource<<bb2a94045026e0f064187e25479dcc01>>
*/
"use strict";
@@ -15630,10 +15630,10 @@ __DEV__ &&
(function () {
var internals = {
bundleType: 1,
version: "19.2.0-native-fb-3ec88e79-20250505",
version: "19.2.0-native-fb-0c1575ce-20250505",
rendererPackageName: "react-test-renderer",
currentDispatcherRef: ReactSharedInternals,
reconcilerVersion: "19.2.0-native-fb-3ec88e79-20250505"
reconcilerVersion: "19.2.0-native-fb-0c1575ce-20250505"
};
internals.overrideHookState = overrideHookState;
internals.overrideHookStateDeletePath = overrideHookStateDeletePath;
@@ -15778,5 +15778,5 @@ __DEV__ &&
flushSyncWorkAcrossRoots_impl(0, !0));
}
};
exports.version = "19.2.0-native-fb-3ec88e79-20250505";
exports.version = "19.2.0-native-fb-0c1575ce-20250505";
})();
@@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<4a0dac2f36b9f3cc223b4634e1d42cdf>>
* @generated SignedSource<<81fd9054662ce7a7a87bc8637d8f7c44>>
*/
"use strict";
@@ -9885,10 +9885,10 @@ function wrapFiber(fiber) {
}
var internals$jscomp$inline_1439 = {
bundleType: 0,
version: "19.2.0-native-fb-3ec88e79-20250505",
version: "19.2.0-native-fb-0c1575ce-20250505",
rendererPackageName: "react-test-renderer",
currentDispatcherRef: ReactSharedInternals,
reconcilerVersion: "19.2.0-native-fb-3ec88e79-20250505"
reconcilerVersion: "19.2.0-native-fb-0c1575ce-20250505"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_1440 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
@@ -10024,4 +10024,4 @@ exports.unstable_batchedUpdates = function (fn, a) {
flushSyncWorkAcrossRoots_impl(0, !0));
}
};
exports.version = "19.2.0-native-fb-3ec88e79-20250505";
exports.version = "19.2.0-native-fb-0c1575ce-20250505";
@@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<d85b11d409c87b54551097b3a9b93456>>
* @generated SignedSource<<aa96c2c8cd30afaf8f03eb57c91cf05e>>
*/
"use strict";
@@ -10502,10 +10502,10 @@ function wrapFiber(fiber) {
}
var internals$jscomp$inline_1247 = {
bundleType: 0,
version: "19.2.0-native-fb-3ec88e79-20250505",
version: "19.2.0-native-fb-0c1575ce-20250505",
rendererPackageName: "react-test-renderer",
currentDispatcherRef: ReactSharedInternals,
reconcilerVersion: "19.2.0-native-fb-3ec88e79-20250505",
reconcilerVersion: "19.2.0-native-fb-0c1575ce-20250505",
getLaneLabelMap: function () {
for (
var map = new Map(), lane = 1, index$155 = 0;
@@ -10656,4 +10656,4 @@ exports.unstable_batchedUpdates = function (fn, a) {
flushSyncWorkAcrossRoots_impl(0, !0));
}
};
exports.version = "19.2.0-native-fb-3ec88e79-20250505";
exports.version = "19.2.0-native-fb-0c1575ce-20250505";
@@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<f587e6473c0586f358045335cdcd84ff>>
* @generated SignedSource<<31d68d46e2a5a2d452273f2f5e4ebbc7>>
*/
"use strict";
@@ -1412,7 +1412,7 @@ __DEV__ &&
exports.useTransition = function () {
return resolveDispatcher().useTransition();
};
exports.version = "19.2.0-native-fb-3ec88e79-20250505";
exports.version = "19.2.0-native-fb-0c1575ce-20250505";
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
"function" ===
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&
@@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<2faf1970b7cfc1202619eafbb688b20d>>
* @generated SignedSource<<7d752be07ac56213bbbcd01f52230fb5>>
*/
"use strict";
@@ -587,4 +587,4 @@ exports.useSyncExternalStore = function (
exports.useTransition = function () {
return ReactSharedInternals.H.useTransition();
};
exports.version = "19.2.0-native-fb-3ec88e79-20250505";
exports.version = "19.2.0-native-fb-0c1575ce-20250505";
@@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<6dd0ac58703b023ff7142560563b4aff>>
* @generated SignedSource<<027ab10abcaaf06961d2c9c3179eb306>>
*/
"use strict";
@@ -591,7 +591,7 @@ exports.useSyncExternalStore = function (
exports.useTransition = function () {
return ReactSharedInternals.H.useTransition();
};
exports.version = "19.2.0-native-fb-3ec88e79-20250505";
exports.version = "19.2.0-native-fb-0c1575ce-20250505";
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
"function" ===
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&
@@ -1 +1 @@
3ec88e797f7352c87cb79292b02fdfc53050133f
0c1575cee8a78dd097edcafc307522ad000e372c
@@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<5cd2afb41fb1f415e3c53e546322b2f2>>
* @generated SignedSource<<f8696b682448a171f3e3802717bb725c>>
*/
"use strict";
@@ -17469,10 +17469,10 @@ __DEV__ &&
(function () {
var internals = {
bundleType: 1,
version: "19.2.0-native-fb-3ec88e79-20250505",
version: "19.2.0-native-fb-0c1575ce-20250505",
rendererPackageName: "react-native-renderer",
currentDispatcherRef: ReactSharedInternals,
reconcilerVersion: "19.2.0-native-fb-3ec88e79-20250505"
reconcilerVersion: "19.2.0-native-fb-0c1575ce-20250505"
};
null !== extraDevToolsConfig &&
(internals.rendererConfig = extraDevToolsConfig);
@@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<db04a60a849e7f319e782e1cbaab563a>>
* @generated SignedSource<<76a6048e2db78c9040f53df5b235888f>>
*/
"use strict";
@@ -11210,10 +11210,10 @@ batchedUpdatesImpl = function (fn, a) {
var roots = new Map(),
internals$jscomp$inline_1251 = {
bundleType: 0,
version: "19.2.0-native-fb-3ec88e79-20250505",
version: "19.2.0-native-fb-0c1575ce-20250505",
rendererPackageName: "react-native-renderer",
currentDispatcherRef: ReactSharedInternals,
reconcilerVersion: "19.2.0-native-fb-3ec88e79-20250505"
reconcilerVersion: "19.2.0-native-fb-0c1575ce-20250505"
};
null !== extraDevToolsConfig &&
(internals$jscomp$inline_1251.rendererConfig = extraDevToolsConfig);
@@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<be66624d999c796fbd990fc076ee28a1>>
* @generated SignedSource<<ea6fb11147e38e6a61863571e1c5326e>>
*/
"use strict";
@@ -11911,10 +11911,10 @@ batchedUpdatesImpl = function (fn, a) {
var roots = new Map(),
internals$jscomp$inline_1352 = {
bundleType: 0,
version: "19.2.0-native-fb-3ec88e79-20250505",
version: "19.2.0-native-fb-0c1575ce-20250505",
rendererPackageName: "react-native-renderer",
currentDispatcherRef: ReactSharedInternals,
reconcilerVersion: "19.2.0-native-fb-3ec88e79-20250505"
reconcilerVersion: "19.2.0-native-fb-0c1575ce-20250505"
};
null !== extraDevToolsConfig &&
(internals$jscomp$inline_1352.rendererConfig = extraDevToolsConfig);
@@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<b913c51080b00382ade119ed54f16140>>
* @generated SignedSource<<3314016ebc3bc3eaa359d377d1b6fdc7>>
*/
"use strict";
@@ -17622,11 +17622,11 @@ __DEV__ &&
shouldSuspendImpl = newShouldSuspendImpl;
};
var isomorphicReactPackageVersion = React.version;
if ("19.2.0-native-fb-3ec88e79-20250505" !== isomorphicReactPackageVersion)
if ("19.2.0-native-fb-0c1575ce-20250505" !== isomorphicReactPackageVersion)
throw Error(
'Incompatible React versions: The "react" and "react-native-renderer" packages must have the exact same version. Instead got:\n - react: ' +
(isomorphicReactPackageVersion +
"\n - react-native-renderer: 19.2.0-native-fb-3ec88e79-20250505\nLearn more: https://react.dev/warnings/version-mismatch")
"\n - react-native-renderer: 19.2.0-native-fb-0c1575ce-20250505\nLearn more: https://react.dev/warnings/version-mismatch")
);
if (
"function" !==
@@ -17652,10 +17652,10 @@ __DEV__ &&
(function () {
var internals = {
bundleType: 1,
version: "19.2.0-native-fb-3ec88e79-20250505",
version: "19.2.0-native-fb-0c1575ce-20250505",
rendererPackageName: "react-native-renderer",
currentDispatcherRef: ReactSharedInternals,
reconcilerVersion: "19.2.0-native-fb-3ec88e79-20250505"
reconcilerVersion: "19.2.0-native-fb-0c1575ce-20250505"
};
null !== extraDevToolsConfig &&
(internals.rendererConfig = extraDevToolsConfig);
@@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<9c541018b07aaa5adaf4fea583bc6f26>>
* @generated SignedSource<<20aeb95a003bfdb06785006688d76b37>>
*/
"use strict";
@@ -11243,11 +11243,11 @@ function updateContainer(element, container, parentComponent, callback) {
return lane;
}
var isomorphicReactPackageVersion = React.version;
if ("19.2.0-native-fb-3ec88e79-20250505" !== isomorphicReactPackageVersion)
if ("19.2.0-native-fb-0c1575ce-20250505" !== isomorphicReactPackageVersion)
throw Error(
'Incompatible React versions: The "react" and "react-native-renderer" packages must have the exact same version. Instead got:\n - react: ' +
(isomorphicReactPackageVersion +
"\n - react-native-renderer: 19.2.0-native-fb-3ec88e79-20250505\nLearn more: https://react.dev/warnings/version-mismatch")
"\n - react-native-renderer: 19.2.0-native-fb-0c1575ce-20250505\nLearn more: https://react.dev/warnings/version-mismatch")
);
if (
"function" !==
@@ -11296,10 +11296,10 @@ batchedUpdatesImpl = function (fn, a) {
var roots = new Map(),
internals$jscomp$inline_1299 = {
bundleType: 0,
version: "19.2.0-native-fb-3ec88e79-20250505",
version: "19.2.0-native-fb-0c1575ce-20250505",
rendererPackageName: "react-native-renderer",
currentDispatcherRef: ReactSharedInternals,
reconcilerVersion: "19.2.0-native-fb-3ec88e79-20250505"
reconcilerVersion: "19.2.0-native-fb-0c1575ce-20250505"
};
null !== extraDevToolsConfig &&
(internals$jscomp$inline_1299.rendererConfig = extraDevToolsConfig);
@@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<a10f6d3487e8038ab405d104619ef1ef>>
* @generated SignedSource<<42a83038c21da0cb145b56effcbe43f1>>
*/
"use strict";
@@ -11942,11 +11942,11 @@ function updateContainer(element, container, parentComponent, callback) {
return lane;
}
var isomorphicReactPackageVersion = React.version;
if ("19.2.0-native-fb-3ec88e79-20250505" !== isomorphicReactPackageVersion)
if ("19.2.0-native-fb-0c1575ce-20250505" !== isomorphicReactPackageVersion)
throw Error(
'Incompatible React versions: The "react" and "react-native-renderer" packages must have the exact same version. Instead got:\n - react: ' +
(isomorphicReactPackageVersion +
"\n - react-native-renderer: 19.2.0-native-fb-3ec88e79-20250505\nLearn more: https://react.dev/warnings/version-mismatch")
"\n - react-native-renderer: 19.2.0-native-fb-0c1575ce-20250505\nLearn more: https://react.dev/warnings/version-mismatch")
);
if (
"function" !==
@@ -11995,10 +11995,10 @@ batchedUpdatesImpl = function (fn, a) {
var roots = new Map(),
internals$jscomp$inline_1400 = {
bundleType: 0,
version: "19.2.0-native-fb-3ec88e79-20250505",
version: "19.2.0-native-fb-0c1575ce-20250505",
rendererPackageName: "react-native-renderer",
currentDispatcherRef: ReactSharedInternals,
reconcilerVersion: "19.2.0-native-fb-3ec88e79-20250505"
reconcilerVersion: "19.2.0-native-fb-0c1575ce-20250505"
};
null !== extraDevToolsConfig &&
(internals$jscomp$inline_1400.rendererConfig = extraDevToolsConfig);
@@ -12,7 +12,7 @@
* @lightSyntaxTransform
* @preventMunge
* @oncall react_core
* @generated SignedSource<<40a04319cda9777bb49ac7840ca620c2>>
* @generated SignedSource<<27f07e15eeb37028edd91a825c302879>>
*/
'use strict';
@@ -45844,19 +45844,42 @@ const EMPTY = new Empty();
function pruneHoistedContexts(fn) {
visitReactiveFunction(fn, new Visitor$8(), {
activeScopes: empty(),
uninitialized: new Map(),
});
}
let Visitor$8 = class Visitor extends ReactiveFunctionTransform {
visitScope(scope, state) {
state.activeScopes = state.activeScopes.push(new Set(scope.scope.declarations.keys()));
for (const decl of scope.scope.declarations.values()) {
state.uninitialized.set(decl.identifier.id, { kind: 'unknown-kind' });
}
this.traverseScope(scope, state);
state.activeScopes.pop();
for (const decl of scope.scope.declarations.values()) {
state.uninitialized.delete(decl.identifier.id);
}
}
visitPlace(_id, place, state) {
const maybeHoistedFn = state.uninitialized.get(place.identifier.id);
if ((maybeHoistedFn === null || maybeHoistedFn === void 0 ? void 0 : maybeHoistedFn.kind) === 'func' &&
maybeHoistedFn.definition !== place) {
CompilerError.throwTodo({
reason: '[PruneHoistedContexts] Rewrite hoisted function references',
loc: place.loc,
});
}
}
transformInstruction(instruction, state) {
this.visitInstruction(instruction, state);
if (instruction.value.kind === 'DeclareContext') {
const maybeNonHoisted = convertHoistedLValueKind(instruction.value.lvalue.kind);
if (maybeNonHoisted != null) {
if (maybeNonHoisted === InstructionKind.Function &&
state.uninitialized.has(instruction.value.lvalue.place.identifier.id)) {
state.uninitialized.set(instruction.value.lvalue.place.identifier.id, {
kind: 'func',
definition: null,
});
}
return { kind: 'remove' };
}
}
@@ -45865,9 +45888,31 @@ let Visitor$8 = class Visitor extends ReactiveFunctionTransform {
const lvalueId = instruction.value.lvalue.place.identifier.id;
const isDeclaredByScope = state.activeScopes.find(scope => scope.has(lvalueId));
if (isDeclaredByScope) {
instruction.value.lvalue.kind = InstructionKind.Reassign;
if (instruction.value.lvalue.kind === InstructionKind.Let ||
instruction.value.lvalue.kind === InstructionKind.Const) {
instruction.value.lvalue.kind = InstructionKind.Reassign;
}
else if (instruction.value.lvalue.kind === InstructionKind.Function) {
const maybeHoistedFn = state.uninitialized.get(lvalueId);
if (maybeHoistedFn != null) {
CompilerError.invariant(maybeHoistedFn.kind === 'func', {
reason: '[PruneHoistedContexts] Unexpected hoisted function',
loc: instruction.loc,
});
maybeHoistedFn.definition = instruction.value.lvalue.place;
state.uninitialized.delete(lvalueId);
}
}
else {
CompilerError.throwTodo({
reason: '[PruneHoistedContexts] Unexpected kind',
description: `(${instruction.value.lvalue.kind})`,
loc: instruction.loc,
});
}
}
}
this.visitInstruction(instruction, state);
return { kind: 'keep' };
}
};
@@ -6,7 +6,7 @@
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
* @generated SignedSource<<e5099a6e93a1b798aa2b13cc58378e11>>
* @generated SignedSource<<77454f7e2e3a65b872ba31d1182709f2>>
*/
'use strict';
@@ -45623,19 +45623,42 @@ const EMPTY = new Empty();
function pruneHoistedContexts(fn) {
visitReactiveFunction(fn, new Visitor$8(), {
activeScopes: empty(),
uninitialized: new Map(),
});
}
let Visitor$8 = class Visitor extends ReactiveFunctionTransform {
visitScope(scope, state) {
state.activeScopes = state.activeScopes.push(new Set(scope.scope.declarations.keys()));
for (const decl of scope.scope.declarations.values()) {
state.uninitialized.set(decl.identifier.id, { kind: 'unknown-kind' });
}
this.traverseScope(scope, state);
state.activeScopes.pop();
for (const decl of scope.scope.declarations.values()) {
state.uninitialized.delete(decl.identifier.id);
}
}
visitPlace(_id, place, state) {
const maybeHoistedFn = state.uninitialized.get(place.identifier.id);
if ((maybeHoistedFn === null || maybeHoistedFn === void 0 ? void 0 : maybeHoistedFn.kind) === 'func' &&
maybeHoistedFn.definition !== place) {
CompilerError.throwTodo({
reason: '[PruneHoistedContexts] Rewrite hoisted function references',
loc: place.loc,
});
}
}
transformInstruction(instruction, state) {
this.visitInstruction(instruction, state);
if (instruction.value.kind === 'DeclareContext') {
const maybeNonHoisted = convertHoistedLValueKind(instruction.value.lvalue.kind);
if (maybeNonHoisted != null) {
if (maybeNonHoisted === InstructionKind.Function &&
state.uninitialized.has(instruction.value.lvalue.place.identifier.id)) {
state.uninitialized.set(instruction.value.lvalue.place.identifier.id, {
kind: 'func',
definition: null,
});
}
return { kind: 'remove' };
}
}
@@ -45644,9 +45667,31 @@ let Visitor$8 = class Visitor extends ReactiveFunctionTransform {
const lvalueId = instruction.value.lvalue.place.identifier.id;
const isDeclaredByScope = state.activeScopes.find(scope => scope.has(lvalueId));
if (isDeclaredByScope) {
instruction.value.lvalue.kind = InstructionKind.Reassign;
if (instruction.value.lvalue.kind === InstructionKind.Let ||
instruction.value.lvalue.kind === InstructionKind.Const) {
instruction.value.lvalue.kind = InstructionKind.Reassign;
}
else if (instruction.value.lvalue.kind === InstructionKind.Function) {
const maybeHoistedFn = state.uninitialized.get(lvalueId);
if (maybeHoistedFn != null) {
CompilerError.invariant(maybeHoistedFn.kind === 'func', {
reason: '[PruneHoistedContexts] Unexpected hoisted function',
loc: instruction.loc,
});
maybeHoistedFn.definition = instruction.value.lvalue.place;
state.uninitialized.delete(lvalueId);
}
}
else {
CompilerError.throwTodo({
reason: '[PruneHoistedContexts] Unexpected kind',
description: `(${instruction.value.lvalue.kind})`,
loc: instruction.loc,
});
}
}
}
this.visitInstruction(instruction, state);
return { kind: 'keep' };
}
};
@@ -1,7 +1,7 @@
{
"name": "eslint-plugin-react-hooks",
"description": "ESLint rules for React Hooks",
"version": "0.0.0-experimental-3ec88e79-20250505",
"version": "0.0.0-experimental-0c1575ce-20250505",
"repository": {
"type": "git",
"url": "https://github.com/facebook/react.git",