Skip to content

Commit badb352

Browse files
committed
[compiler][ez] Only fail gating hoisting check for referenced identifiers (#32596)
Reduce false positive bailouts by using the same `isReferencedIdentifier` logic that the compiler also uses for determining context variables and a function's own hoisted declarations. Details: Previously, we counted every babel identifier as a reference. This is problematic because babel counts most string symbols as an identifier. ```js print(x); // x is an identifier as expected obj.x // x is.. also an identifier here {x: 2} // x is also an identifier here ``` This PR adds a check for `isReferencedIdentifier`. Note that only non-lval references pass this check. This should be fine as we don't need to hoist function declarations before writes to the same lvalue (which should error in strict mode anyways) ```js print(x); // isReferencedIdentifier(x) -> true obj.x // isReferencedIdentifier(x) -> false {x: 2} // isReferencedIdentifier(x) -> false x = 2 // isReferencedIdentifier(x) -> false ``` --- [//]: # (BEGIN SAPLING FOOTER) Stack created with [Sapling](https://sapling-scm.com). Best reviewed with [ReviewStack](https://reviewstack.dev/facebook/react/pull/32596). * __->__ #32596 * #32595 * #32594 * #32593 * #32522 * #32521 DiffTrain build for [f457d0b](f457d0b)
1 parent 4a02d71 commit badb352

35 files changed

+87
-87
lines changed

compiled/facebook-www/REVISION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1c79cb82ab8d3bd1f099115704f28df1097beb46
1+
f457d0b4c6dd70c10acb9c93c7d01c80d8e23b92
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1c79cb82ab8d3bd1f099115704f28df1097beb46
1+
f457d0b4c6dd70c10acb9c93c7d01c80d8e23b92

compiled/facebook-www/React-dev.classic.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1532,7 +1532,7 @@ __DEV__ &&
15321532
exports.useTransition = function () {
15331533
return resolveDispatcher().useTransition();
15341534
};
1535-
exports.version = "19.1.0-www-classic-89a46a57-20250313";
1535+
exports.version = "19.1.0-www-classic-f457d0b4-20250313";
15361536
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
15371537
"function" ===
15381538
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

compiled/facebook-www/React-dev.modern.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1532,7 +1532,7 @@ __DEV__ &&
15321532
exports.useTransition = function () {
15331533
return resolveDispatcher().useTransition();
15341534
};
1535-
exports.version = "19.1.0-www-modern-89a46a57-20250313";
1535+
exports.version = "19.1.0-www-modern-f457d0b4-20250313";
15361536
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
15371537
"function" ===
15381538
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

compiled/facebook-www/React-prod.classic.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -641,4 +641,4 @@ exports.useSyncExternalStore = function (
641641
exports.useTransition = function () {
642642
return ReactSharedInternals.H.useTransition();
643643
};
644-
exports.version = "19.1.0-www-classic-89a46a57-20250313";
644+
exports.version = "19.1.0-www-classic-f457d0b4-20250313";

compiled/facebook-www/React-prod.modern.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -641,4 +641,4 @@ exports.useSyncExternalStore = function (
641641
exports.useTransition = function () {
642642
return ReactSharedInternals.H.useTransition();
643643
};
644-
exports.version = "19.1.0-www-modern-89a46a57-20250313";
644+
exports.version = "19.1.0-www-modern-f457d0b4-20250313";

compiled/facebook-www/React-profiling.classic.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -645,7 +645,7 @@ exports.useSyncExternalStore = function (
645645
exports.useTransition = function () {
646646
return ReactSharedInternals.H.useTransition();
647647
};
648-
exports.version = "19.1.0-www-classic-89a46a57-20250313";
648+
exports.version = "19.1.0-www-classic-f457d0b4-20250313";
649649
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
650650
"function" ===
651651
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

compiled/facebook-www/React-profiling.modern.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -645,7 +645,7 @@ exports.useSyncExternalStore = function (
645645
exports.useTransition = function () {
646646
return ReactSharedInternals.H.useTransition();
647647
};
648-
exports.version = "19.1.0-www-modern-89a46a57-20250313";
648+
exports.version = "19.1.0-www-modern-f457d0b4-20250313";
649649
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
650650
"function" ===
651651
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

compiled/facebook-www/ReactART-dev.classic.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18546,10 +18546,10 @@ __DEV__ &&
1854618546
(function () {
1854718547
var internals = {
1854818548
bundleType: 1,
18549-
version: "19.1.0-www-classic-89a46a57-20250313",
18549+
version: "19.1.0-www-classic-f457d0b4-20250313",
1855018550
rendererPackageName: "react-art",
1855118551
currentDispatcherRef: ReactSharedInternals,
18552-
reconcilerVersion: "19.1.0-www-classic-89a46a57-20250313"
18552+
reconcilerVersion: "19.1.0-www-classic-f457d0b4-20250313"
1855318553
};
1855418554
internals.overrideHookState = overrideHookState;
1855518555
internals.overrideHookStateDeletePath = overrideHookStateDeletePath;
@@ -18583,7 +18583,7 @@ __DEV__ &&
1858318583
exports.Shape = Shape;
1858418584
exports.Surface = Surface;
1858518585
exports.Text = Text;
18586-
exports.version = "19.1.0-www-classic-89a46a57-20250313";
18586+
exports.version = "19.1.0-www-classic-f457d0b4-20250313";
1858718587
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
1858818588
"function" ===
1858918589
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

compiled/facebook-www/ReactART-dev.modern.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18318,10 +18318,10 @@ __DEV__ &&
1831818318
(function () {
1831918319
var internals = {
1832018320
bundleType: 1,
18321-
version: "19.1.0-www-modern-89a46a57-20250313",
18321+
version: "19.1.0-www-modern-f457d0b4-20250313",
1832218322
rendererPackageName: "react-art",
1832318323
currentDispatcherRef: ReactSharedInternals,
18324-
reconcilerVersion: "19.1.0-www-modern-89a46a57-20250313"
18324+
reconcilerVersion: "19.1.0-www-modern-f457d0b4-20250313"
1832518325
};
1832618326
internals.overrideHookState = overrideHookState;
1832718327
internals.overrideHookStateDeletePath = overrideHookStateDeletePath;
@@ -18355,7 +18355,7 @@ __DEV__ &&
1835518355
exports.Shape = Shape;
1835618356
exports.Surface = Surface;
1835718357
exports.Text = Text;
18358-
exports.version = "19.1.0-www-modern-89a46a57-20250313";
18358+
exports.version = "19.1.0-www-modern-f457d0b4-20250313";
1835918359
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
1836018360
"function" ===
1836118361
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

0 commit comments

Comments
 (0)