From 45b4735773068fc39cc07bbe4814d46b825d4b91 Mon Sep 17 00:00:00 2001 From: mofeiZ Date: Mon, 5 May 2025 08:52:26 -0700 Subject: [PATCH] [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 [0c1575cee8a78dd097edcafc307522ad000e372c](https://github.com/facebook/react/commit/0c1575cee8a78dd097edcafc307522ad000e372c) --- compiled-rn/VERSION_NATIVE_FB | 2 +- .../react/react-dom/cjs/ReactDOM-dev.js | 4 +- .../react/react-dom/cjs/ReactDOM-prod.js | 4 +- .../react/react-dom/cjs/ReactDOM-profiling.js | 4 +- .../react/react-dom/cjs/ReactDOMClient-dev.js | 12 ++--- .../react-dom/cjs/ReactDOMClient-prod.js | 12 ++--- .../react-dom/cjs/ReactDOMClient-profiling.js | 12 ++--- .../react-dom/cjs/ReactDOMProfiling-dev.js | 12 ++--- .../react-dom/cjs/ReactDOMProfiling-prod.js | 12 ++--- .../cjs/ReactDOMProfiling-profiling.js | 12 ++--- .../cjs/ReactTestRenderer-dev.js | 8 +-- .../cjs/ReactTestRenderer-prod.js | 8 +-- .../cjs/ReactTestRenderer-profiling.js | 8 +-- .../vendor/react/react/cjs/React-dev.js | 4 +- .../vendor/react/react/cjs/React-prod.js | 4 +- .../vendor/react/react/cjs/React-profiling.js | 4 +- .../Libraries/Renderer/REVISION | 2 +- .../implementations/ReactFabric-dev.fb.js | 6 +-- .../implementations/ReactFabric-prod.fb.js | 6 +-- .../ReactFabric-profiling.fb.js | 6 +-- .../ReactNativeRenderer-dev.fb.js | 10 ++-- .../ReactNativeRenderer-prod.fb.js | 10 ++-- .../ReactNativeRenderer-profiling.fb.js | 10 ++-- .../eslint-plugin-react-hooks.development.js | 51 +++++++++++++++++-- .../eslint-plugin-react-hooks.production.js | 51 +++++++++++++++++-- .../eslint-plugin-react-hooks/package.json | 2 +- 26 files changed, 183 insertions(+), 93 deletions(-) diff --git a/compiled-rn/VERSION_NATIVE_FB b/compiled-rn/VERSION_NATIVE_FB index ceaeebdef0..4a89c3b35b 100644 --- a/compiled-rn/VERSION_NATIVE_FB +++ b/compiled-rn/VERSION_NATIVE_FB @@ -1 +1 @@ -19.2.0-native-fb-3ec88e79-20250505 \ No newline at end of file +19.2.0-native-fb-0c1575ce-20250505 \ No newline at end of file diff --git a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOM-dev.js b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOM-dev.js index 2d45a550e2..f6d035613b 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOM-dev.js +++ b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOM-dev.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<<1c9b2192c6ad951c0c453a1c800f767e>> + * @generated SignedSource<> */ "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"; })(); diff --git a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOM-prod.js b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOM-prod.js index a3d9e73c14..38f6a906d2 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOM-prod.js +++ b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOM-prod.js @@ -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"; diff --git a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOM-profiling.js b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOM-profiling.js index a3d9e73c14..38f6a906d2 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOM-profiling.js +++ b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOM-profiling.js @@ -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"; diff --git a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMClient-dev.js b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMClient-dev.js index f6ea6c3114..82401007e7 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMClient-dev.js +++ b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMClient-dev.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<> + * @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"; })(); diff --git a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMClient-prod.js b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMClient-prod.js index 63fa4406ee..79a49a949a 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMClient-prod.js +++ b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMClient-prod.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<<7a50b7821bd51921ccacb330ca49a0fe>> + * @generated SignedSource<> */ /* @@ -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"; diff --git a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMClient-profiling.js b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMClient-profiling.js index a5a8d1d8dc..fab7885ad8 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMClient-profiling.js +++ b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMClient-profiling.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<> + * @generated SignedSource<> */ /* @@ -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"; diff --git a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMProfiling-dev.js b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMProfiling-dev.js index 46b304cf79..515eb11cfd 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMProfiling-dev.js +++ b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMProfiling-dev.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<> + * @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 && diff --git a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMProfiling-prod.js b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMProfiling-prod.js index 1fe15b72b0..94aaa67797 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMProfiling-prod.js +++ b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMProfiling-prod.js @@ -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"; diff --git a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMProfiling-profiling.js b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMProfiling-profiling.js index ee6686972c..ef65aefb83 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMProfiling-profiling.js +++ b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMProfiling-profiling.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<<0eeb759e7bc62377bc794462ee0aee69>> + * @generated SignedSource<> */ /* @@ -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 && diff --git a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-test-renderer/cjs/ReactTestRenderer-dev.js b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-test-renderer/cjs/ReactTestRenderer-dev.js index 94fc07328d..017bbe100e 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-test-renderer/cjs/ReactTestRenderer-dev.js +++ b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-test-renderer/cjs/ReactTestRenderer-dev.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<<3c6d2f14703d6a109a6a1d7984679413>> + * @generated SignedSource<> */ "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"; })(); diff --git a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-test-renderer/cjs/ReactTestRenderer-prod.js b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-test-renderer/cjs/ReactTestRenderer-prod.js index 3d4e71f7dc..2a2eaee757 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-test-renderer/cjs/ReactTestRenderer-prod.js +++ b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-test-renderer/cjs/ReactTestRenderer-prod.js @@ -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"; diff --git a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-test-renderer/cjs/ReactTestRenderer-profiling.js b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-test-renderer/cjs/ReactTestRenderer-profiling.js index 363ebfcc0e..4c8accfe7e 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-test-renderer/cjs/ReactTestRenderer-profiling.js +++ b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-test-renderer/cjs/ReactTestRenderer-profiling.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<> + * @generated SignedSource<> */ "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"; diff --git a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react/cjs/React-dev.js b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react/cjs/React-dev.js index 1ffb57b2fa..736c0bf635 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react/cjs/React-dev.js +++ b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react/cjs/React-dev.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<> + * @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 && diff --git a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react/cjs/React-prod.js b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react/cjs/React-prod.js index f7880af1e5..5d6b045173 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react/cjs/React-prod.js +++ b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react/cjs/React-prod.js @@ -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"; diff --git a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react/cjs/React-profiling.js b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react/cjs/React-profiling.js index ef8aa705a4..63f4023a9d 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react/cjs/React-profiling.js +++ b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react/cjs/React-profiling.js @@ -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 && diff --git a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/REVISION b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/REVISION index b607cdbadd..11154632ec 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/REVISION +++ b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/REVISION @@ -1 +1 @@ -3ec88e797f7352c87cb79292b02fdfc53050133f +0c1575cee8a78dd097edcafc307522ad000e372c diff --git a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-dev.fb.js b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-dev.fb.js index f8ea599f00..4876f65fc8 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-dev.fb.js +++ b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-dev.fb.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<<5cd2afb41fb1f415e3c53e546322b2f2>> + * @generated SignedSource<> */ "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); diff --git a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-prod.fb.js b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-prod.fb.js index 2a9cbd3cb7..4211b766da 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-prod.fb.js +++ b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-prod.fb.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<> + * @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); diff --git a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-profiling.fb.js b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-profiling.fb.js index 163cd133c3..ec57e953d9 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-profiling.fb.js +++ b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-profiling.fb.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<> + * @generated SignedSource<> */ "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); diff --git a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-dev.fb.js b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-dev.fb.js index 721c87c2d2..031dd91c61 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-dev.fb.js +++ b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-dev.fb.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<> + * @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); diff --git a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-prod.fb.js b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-prod.fb.js index ba73a08eaa..a27a5a476b 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-prod.fb.js +++ b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-prod.fb.js @@ -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); diff --git a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.fb.js b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.fb.js index 4a3de8911a..f3baec6c75 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.fb.js +++ b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.fb.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<> + * @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); diff --git a/compiled-rn/facebook-fbsource/xplat/js/tools/eslint-plugin-react-hooks/cjs/eslint-plugin-react-hooks.development.js b/compiled-rn/facebook-fbsource/xplat/js/tools/eslint-plugin-react-hooks/cjs/eslint-plugin-react-hooks.development.js index fc047a1929..5fe38428ce 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/tools/eslint-plugin-react-hooks/cjs/eslint-plugin-react-hooks.development.js +++ b/compiled-rn/facebook-fbsource/xplat/js/tools/eslint-plugin-react-hooks/cjs/eslint-plugin-react-hooks.development.js @@ -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' }; } }; diff --git a/compiled-rn/facebook-fbsource/xplat/js/tools/eslint-plugin-react-hooks/cjs/eslint-plugin-react-hooks.production.js b/compiled-rn/facebook-fbsource/xplat/js/tools/eslint-plugin-react-hooks/cjs/eslint-plugin-react-hooks.production.js index db0fbdbf59..306417fddf 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/tools/eslint-plugin-react-hooks/cjs/eslint-plugin-react-hooks.production.js +++ b/compiled-rn/facebook-fbsource/xplat/js/tools/eslint-plugin-react-hooks/cjs/eslint-plugin-react-hooks.production.js @@ -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<> + * @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' }; } }; diff --git a/compiled-rn/facebook-fbsource/xplat/js/tools/eslint-plugin-react-hooks/package.json b/compiled-rn/facebook-fbsource/xplat/js/tools/eslint-plugin-react-hooks/package.json index d6c9f3b82a..06116ab213 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/tools/eslint-plugin-react-hooks/package.json +++ b/compiled-rn/facebook-fbsource/xplat/js/tools/eslint-plugin-react-hooks/package.json @@ -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",