Skip to content

Commit 1796cb9

Browse files
committed
[compiler] Fix bug with reassigning function param in destructuring (#33624)
Closes #33577, a bug with ExtractScopeDeclarationsFromDestructuring and codegen when a function param is reassigned. --- [//]: # (BEGIN SAPLING FOOTER) Stack created with [Sapling](https://sapling-scm.com). Best reviewed with [ReviewStack](https://reviewstack.dev/facebook/react/pull/33624). * #33643 * #33642 * #33640 * #33625 * __->__ #33624 DiffTrain build for [9894c48](9894c48)
1 parent 59b07a2 commit 1796cb9

35 files changed

+100
-100
lines changed

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

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27076,9 +27076,6 @@ function printFunction(fn) {
2707627076
if (fn.id !== null) {
2707727077
definition += fn.id;
2707827078
}
27079-
else {
27080-
definition += '<<anonymous>>';
27081-
}
2708227079
if (fn.params.length !== 0) {
2708327080
definition +=
2708427081
'(' +
@@ -27097,8 +27094,10 @@ function printFunction(fn) {
2709727094
else {
2709827095
definition += '()';
2709927096
}
27100-
definition += `: ${printPlace(fn.returns)}`;
27101-
output.push(definition);
27097+
if (definition.length !== 0) {
27098+
output.push(definition);
27099+
}
27100+
output.push(`: ${printType(fn.returnType)} @ ${printPlace(fn.returns)}`);
2710227101
output.push(...fn.directives);
2710327102
output.push(printHIR(fn.body));
2710427103
return output.join('\n');
@@ -30923,6 +30922,7 @@ function lower$1(func, env, bindings = null, capturedRefs = new Map()) {
3092330922
params,
3092430923
fnType: bindings == null ? env.fnType : 'Other',
3092530924
returnTypeAnnotation: null,
30925+
returnType: makeType(),
3092630926
returns: createTemporaryPlace(env, (_b = func.node.loc) !== null && _b !== void 0 ? _b : GeneratedSource),
3092730927
body: builder.build(),
3092830928
context,
@@ -44546,7 +44546,7 @@ function codegenTerminal(cx, terminal) {
4454644546
? codegenPlaceToExpression(cx, case_.test)
4454744547
: null;
4454844548
const block = codegenBlock(cx, case_.block);
44549-
return libExports$1.switchCase(test, block.body.length === 0 ? [] : [block]);
44549+
return libExports$1.switchCase(test, [block]);
4455044550
}));
4455144551
}
4455244552
case 'throw': {
@@ -51683,13 +51683,12 @@ function inferMutationAliasingRanges(fn, { isFunctionExpression }) {
5168351683
}
5168451684
}
5168551685
}
51686-
const returns = fn.returns.identifier;
5168751686
functionEffects.push({
5168851687
kind: 'Create',
5168951688
into: fn.returns,
51690-
value: isPrimitiveType(returns)
51689+
value: fn.returnType.kind === 'Primitive'
5169151690
? ValueKind.Primitive
51692-
: isJsxType(returns.type)
51691+
: isJsxType(fn.returnType)
5169351692
? ValueKind.Frozen
5169451693
: ValueKind.Mutable,
5169551694
reason: ValueReason.KnownReturnSignature,
@@ -55273,8 +55272,7 @@ function apply(func, unifier) {
5527355272
}
5527455273
}
5527555274
}
55276-
const returns = func.returns.identifier;
55277-
returns.type = unifier.get(returns.type);
55275+
func.returnType = unifier.get(func.returnType);
5527855276
}
5527955277
function equation(left, right) {
5528055278
return {
@@ -55316,13 +55314,13 @@ function* generate(func) {
5531655314
}
5531755315
}
5531855316
if (returnTypes.length > 1) {
55319-
yield equation(func.returns.identifier.type, {
55317+
yield equation(func.returnType, {
5532055318
kind: 'Phi',
5532155319
operands: returnTypes,
5532255320
});
5532355321
}
5532455322
else if (returnTypes.length === 1) {
55325-
yield equation(func.returns.identifier.type, returnTypes[0]);
55323+
yield equation(func.returnType, returnTypes[0]);
5532655324
}
5532755325
}
5532855326
function setName(names, id, name) {
@@ -55533,7 +55531,7 @@ function* generateInstructionTypes(env, names, instr) {
5553355531
yield equation(left, {
5553455532
kind: 'Function',
5553555533
shapeId: BuiltInFunctionId,
55536-
return: value.loweredFunc.func.returns.identifier.type,
55534+
return: value.loweredFunc.func.returnType,
5553755535
isConstructor: false,
5553855536
});
5553955537
break;
@@ -57676,6 +57674,7 @@ function emitSelectorFn(env, keys) {
5767657674
env,
5767757675
params: [obj],
5767857676
returnTypeAnnotation: null,
57677+
returnType: makeType(),
5767957678
returns: createTemporaryPlace(env, GeneratedSource),
5768057679
context: [],
5768157680
effects: null,
@@ -58093,6 +58092,7 @@ function emitOutlinedFn(env, jsx, oldProps, globals) {
5809358092
env,
5809458093
params: [propsObj],
5809558094
returnTypeAnnotation: null,
58095+
returnType: makeType(),
5809658096
returns: createTemporaryPlace(env, GeneratedSource),
5809758097
context: [],
5809858098
effects: null,

compiled/facebook-www/REVISION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
123ff13b193cd361a61b99056dd08f2decd7f55d
1+
9894c488e0d9a4d9759d80ba8666d4d094b894e9
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
123ff13b193cd361a61b99056dd08f2decd7f55d
1+
9894c488e0d9a4d9759d80ba8666d4d094b894e9

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1479,7 +1479,7 @@ __DEV__ &&
14791479
exports.useTransition = function () {
14801480
return resolveDispatcher().useTransition();
14811481
};
1482-
exports.version = "19.2.0-www-classic-123ff13b-20250625";
1482+
exports.version = "19.2.0-www-classic-9894c488-20250625";
14831483
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
14841484
"function" ===
14851485
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
@@ -1479,7 +1479,7 @@ __DEV__ &&
14791479
exports.useTransition = function () {
14801480
return resolveDispatcher().useTransition();
14811481
};
1482-
exports.version = "19.2.0-www-modern-123ff13b-20250625";
1482+
exports.version = "19.2.0-www-modern-9894c488-20250625";
14831483
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
14841484
"function" ===
14851485
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
@@ -630,4 +630,4 @@ exports.useSyncExternalStore = function (
630630
exports.useTransition = function () {
631631
return ReactSharedInternals.H.useTransition();
632632
};
633-
exports.version = "19.2.0-www-classic-123ff13b-20250625";
633+
exports.version = "19.2.0-www-classic-9894c488-20250625";

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -630,4 +630,4 @@ exports.useSyncExternalStore = function (
630630
exports.useTransition = function () {
631631
return ReactSharedInternals.H.useTransition();
632632
};
633-
exports.version = "19.2.0-www-modern-123ff13b-20250625";
633+
exports.version = "19.2.0-www-modern-9894c488-20250625";

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,7 @@ exports.useSyncExternalStore = function (
634634
exports.useTransition = function () {
635635
return ReactSharedInternals.H.useTransition();
636636
};
637-
exports.version = "19.2.0-www-classic-123ff13b-20250625";
637+
exports.version = "19.2.0-www-classic-9894c488-20250625";
638638
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
639639
"function" ===
640640
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
@@ -634,7 +634,7 @@ exports.useSyncExternalStore = function (
634634
exports.useTransition = function () {
635635
return ReactSharedInternals.H.useTransition();
636636
};
637-
exports.version = "19.2.0-www-modern-123ff13b-20250625";
637+
exports.version = "19.2.0-www-modern-9894c488-20250625";
638638
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
639639
"function" ===
640640
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
@@ -19073,10 +19073,10 @@ __DEV__ &&
1907319073
(function () {
1907419074
var internals = {
1907519075
bundleType: 1,
19076-
version: "19.2.0-www-classic-123ff13b-20250625",
19076+
version: "19.2.0-www-classic-9894c488-20250625",
1907719077
rendererPackageName: "react-art",
1907819078
currentDispatcherRef: ReactSharedInternals,
19079-
reconcilerVersion: "19.2.0-www-classic-123ff13b-20250625"
19079+
reconcilerVersion: "19.2.0-www-classic-9894c488-20250625"
1908019080
};
1908119081
internals.overrideHookState = overrideHookState;
1908219082
internals.overrideHookStateDeletePath = overrideHookStateDeletePath;
@@ -19110,7 +19110,7 @@ __DEV__ &&
1911019110
exports.Shape = Shape;
1911119111
exports.Surface = Surface;
1911219112
exports.Text = Text;
19113-
exports.version = "19.2.0-www-classic-123ff13b-20250625";
19113+
exports.version = "19.2.0-www-classic-9894c488-20250625";
1911419114
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
1911519115
"function" ===
1911619116
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

0 commit comments

Comments
 (0)