Skip to content

Commit 579b9bf

Browse files
committed
[compiler] Emit better error for unsupported syntax this (#34322)
DiffTrain build for [bd5b1b7](bd5b1b7)
1 parent 5944537 commit 579b9bf

35 files changed

+103
-88
lines changed

compiled/eslint-plugin-react-hooks/index.js

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21088,7 +21088,7 @@ class HIRBuilder {
2108821088
}
2108921089
}
2109021090
resolveBinding(node) {
21091-
var _a, _b;
21091+
var _a, _b, _c;
2109221092
if (node.name === 'fbt') {
2109321093
CompilerError.throwDiagnostic({
2109421094
severity: ErrorSeverity.Todo,
@@ -21104,6 +21104,21 @@ class HIRBuilder {
2110421104
],
2110521105
});
2110621106
}
21107+
if (node.name === 'this') {
21108+
CompilerError.throwDiagnostic({
21109+
severity: ErrorSeverity.UnsupportedJS,
21110+
category: ErrorCategory.UnsupportedSyntax,
21111+
reason: '`this` is not supported syntax',
21112+
description: 'React Compiler does not support compiling functions that use `this`',
21113+
details: [
21114+
{
21115+
kind: 'error',
21116+
message: '`this` was used here',
21117+
loc: (_b = node.loc) !== null && _b !== void 0 ? _b : GeneratedSource,
21118+
},
21119+
],
21120+
});
21121+
}
2110721122
const originalName = node.name;
2110821123
let name = originalName;
2110921124
let index = 0;
@@ -21121,7 +21136,7 @@ class HIRBuilder {
2112121136
},
2112221137
scope: null,
2112321138
type: makeType(),
21124-
loc: (_b = node.loc) !== null && _b !== void 0 ? _b : GeneratedSource,
21139+
loc: (_c = node.loc) !== null && _c !== void 0 ? _c : GeneratedSource,
2112521140
};
2112621141
__classPrivateFieldGet(this, _HIRBuilder_env, "f").programContext.addNewReference(name);
2112721142
__classPrivateFieldGet(this, _HIRBuilder_bindings, "f").set(name, { node, identifier });

compiled/facebook-www/REVISION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
b870042915c8a7cc1524feb7e0b5cbe7453a7648
1+
bd5b1b7639b818a3fbd33ce83bf022a6f9f27b55
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
b870042915c8a7cc1524feb7e0b5cbe7453a7648
1+
bd5b1b7639b818a3fbd33ce83bf022a6f9f27b55

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1409,7 +1409,7 @@ __DEV__ &&
14091409
exports.useTransition = function () {
14101410
return resolveDispatcher().useTransition();
14111411
};
1412-
exports.version = "19.2.0-www-classic-b8700429-20250827";
1412+
exports.version = "19.2.0-www-classic-bd5b1b76-20250827";
14131413
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
14141414
"function" ===
14151415
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
@@ -1409,7 +1409,7 @@ __DEV__ &&
14091409
exports.useTransition = function () {
14101410
return resolveDispatcher().useTransition();
14111411
};
1412-
exports.version = "19.2.0-www-modern-b8700429-20250827";
1412+
exports.version = "19.2.0-www-modern-bd5b1b76-20250827";
14131413
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
14141414
"function" ===
14151415
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
@@ -600,4 +600,4 @@ exports.useSyncExternalStore = function (
600600
exports.useTransition = function () {
601601
return ReactSharedInternals.H.useTransition();
602602
};
603-
exports.version = "19.2.0-www-classic-b8700429-20250827";
603+
exports.version = "19.2.0-www-classic-bd5b1b76-20250827";

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -600,4 +600,4 @@ exports.useSyncExternalStore = function (
600600
exports.useTransition = function () {
601601
return ReactSharedInternals.H.useTransition();
602602
};
603-
exports.version = "19.2.0-www-modern-b8700429-20250827";
603+
exports.version = "19.2.0-www-modern-bd5b1b76-20250827";

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,7 @@ exports.useSyncExternalStore = function (
604604
exports.useTransition = function () {
605605
return ReactSharedInternals.H.useTransition();
606606
};
607-
exports.version = "19.2.0-www-classic-b8700429-20250827";
607+
exports.version = "19.2.0-www-classic-bd5b1b76-20250827";
608608
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
609609
"function" ===
610610
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
@@ -604,7 +604,7 @@ exports.useSyncExternalStore = function (
604604
exports.useTransition = function () {
605605
return ReactSharedInternals.H.useTransition();
606606
};
607-
exports.version = "19.2.0-www-modern-b8700429-20250827";
607+
exports.version = "19.2.0-www-modern-bd5b1b76-20250827";
608608
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
609609
"function" ===
610610
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
@@ -19588,10 +19588,10 @@ __DEV__ &&
1958819588
(function () {
1958919589
var internals = {
1959019590
bundleType: 1,
19591-
version: "19.2.0-www-classic-b8700429-20250827",
19591+
version: "19.2.0-www-classic-bd5b1b76-20250827",
1959219592
rendererPackageName: "react-art",
1959319593
currentDispatcherRef: ReactSharedInternals,
19594-
reconcilerVersion: "19.2.0-www-classic-b8700429-20250827"
19594+
reconcilerVersion: "19.2.0-www-classic-bd5b1b76-20250827"
1959519595
};
1959619596
internals.overrideHookState = overrideHookState;
1959719597
internals.overrideHookStateDeletePath = overrideHookStateDeletePath;
@@ -19625,7 +19625,7 @@ __DEV__ &&
1962519625
exports.Shape = Shape;
1962619626
exports.Surface = Surface;
1962719627
exports.Text = Text;
19628-
exports.version = "19.2.0-www-classic-b8700429-20250827";
19628+
exports.version = "19.2.0-www-classic-bd5b1b76-20250827";
1962919629
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
1963019630
"function" ===
1963119631
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

0 commit comments

Comments
 (0)