@@ -19518,6 +19518,7 @@ function getFunctionName$2(instrValue, defaultValue) {
1951819518 }
1951919519}
1952019520function printAliasingEffect(effect) {
19521+ var _a;
1952119522 switch (effect.kind) {
1952219523 case 'Assign': {
1952319524 return `Assign ${printPlaceForAliasEffect(effect.into)} = ${printPlaceForAliasEffect(effect.from)}`;
@@ -19576,7 +19577,7 @@ function printAliasingEffect(effect) {
1957619577 case 'MutateConditionally':
1957719578 case 'MutateTransitive':
1957819579 case 'MutateTransitiveConditionally': {
19579- return `${effect.kind} ${printPlaceForAliasEffect(effect.value)}`;
19580+ return `${effect.kind} ${printPlaceForAliasEffect(effect.value)}${effect.kind === 'Mutate' && ((_a = effect.reason) === null || _a === void 0 ? void 0 : _a.kind) === 'AssignCurrentProperty' ? ' (assign `.current`)' : ''} `;
1958019581 }
1958119582 case 'MutateFrozen': {
1958219583 return `MutateFrozen ${printPlaceForAliasEffect(effect.place)} reason=${JSON.stringify(effect.error.reason)}`;
@@ -21088,7 +21089,7 @@ class HIRBuilder {
2108821089 }
2108921090 }
2109021091 resolveBinding(node) {
21091- var _a, _b;
21092+ var _a, _b, _c ;
2109221093 if (node.name === 'fbt') {
2109321094 CompilerError.throwDiagnostic({
2109421095 severity: ErrorSeverity.Todo,
@@ -21104,6 +21105,21 @@ class HIRBuilder {
2110421105 ],
2110521106 });
2110621107 }
21108+ if (node.name === 'this') {
21109+ CompilerError.throwDiagnostic({
21110+ severity: ErrorSeverity.UnsupportedJS,
21111+ category: ErrorCategory.UnsupportedSyntax,
21112+ reason: '`this` is not supported syntax',
21113+ description: 'React Compiler does not support compiling functions that use `this`',
21114+ details: [
21115+ {
21116+ kind: 'error',
21117+ message: '`this` was used here',
21118+ loc: (_b = node.loc) !== null && _b !== void 0 ? _b : GeneratedSource,
21119+ },
21120+ ],
21121+ });
21122+ }
2110721123 const originalName = node.name;
2110821124 let name = originalName;
2110921125 let index = 0;
@@ -21121,7 +21137,7 @@ class HIRBuilder {
2112121137 },
2112221138 scope: null,
2112321139 type: makeType(),
21124- loc: (_b = node.loc) !== null && _b !== void 0 ? _b : GeneratedSource,
21140+ loc: (_c = node.loc) !== null && _c !== void 0 ? _c : GeneratedSource,
2112521141 };
2112621142 __classPrivateFieldGet(this, _HIRBuilder_env, "f").programContext.addNewReference(name);
2112721143 __classPrivateFieldGet(this, _HIRBuilder_bindings, "f").set(name, { node, identifier });
@@ -42298,7 +42314,7 @@ class RewriteBlockIds extends ReactiveFunctionVisitor {
4229842314}
4229942315
4230042316function inferMutationAliasingRanges(fn, { isFunctionExpression }) {
42301- var _a, _b, _c, _d, _e, _f;
42317+ var _a, _b, _c, _d, _e, _f, _g ;
4230242318 const functionEffects = [];
4230342319 const state = new AliasingState();
4230442320 const pendingPhis = new Map();
@@ -42365,6 +42381,7 @@ function inferMutationAliasingRanges(fn, { isFunctionExpression }) {
4236542381 kind: effect.kind === 'MutateTransitive'
4236642382 ? MutationKind.Definite
4236742383 : MutationKind.Conditional,
42384+ reason: null,
4236842385 place: effect.value,
4236942386 });
4237042387 }
@@ -42377,6 +42394,7 @@ function inferMutationAliasingRanges(fn, { isFunctionExpression }) {
4237742394 kind: effect.kind === 'Mutate'
4237842395 ? MutationKind.Definite
4237942396 : MutationKind.Conditional,
42397+ reason: effect.kind === 'Mutate' ? ((_a = effect.reason) !== null && _a !== void 0 ? _a : null) : null,
4238042398 place: effect.value,
4238142399 });
4238242400 }
@@ -42418,7 +42436,7 @@ function inferMutationAliasingRanges(fn, { isFunctionExpression }) {
4241842436 }
4241942437 }
4242042438 for (const mutation of mutations) {
42421- state.mutate(mutation.index, mutation.place.identifier, makeInstructionId(mutation.id + 1), mutation.transitive, mutation.kind, mutation.place.loc, errors);
42439+ state.mutate(mutation.index, mutation.place.identifier, makeInstructionId(mutation.id + 1), mutation.transitive, mutation.kind, mutation.place.loc, mutation.reason, errors);
4242242440 }
4242342441 for (const render of renders) {
4242442442 state.render(render.index, render.place.identifier, errors);
@@ -42443,6 +42461,7 @@ function inferMutationAliasingRanges(fn, { isFunctionExpression }) {
4244342461 functionEffects.push({
4244442462 kind: 'Mutate',
4244542463 value: Object.assign(Object.assign({}, place), { loc: node.local.loc }),
42464+ reason: node.mutationReason,
4244642465 });
4244742466 }
4244842467 }
@@ -42470,15 +42489,15 @@ function inferMutationAliasingRanges(fn, { isFunctionExpression }) {
4247042489 for (const phi of block.phis) {
4247142490 phi.place.effect = Effect.Store;
4247242491 const isPhiMutatedAfterCreation = phi.place.identifier.mutableRange.end >
42473- ((_b = (_a = block.instructions.at(0)) === null || _a === void 0 ? void 0 : _a .id) !== null && _b !== void 0 ? _b : block.terminal.id);
42492+ ((_c = (_b = block.instructions.at(0)) === null || _b === void 0 ? void 0 : _b .id) !== null && _c !== void 0 ? _c : block.terminal.id);
4247442493 for (const operand of phi.operands.values()) {
4247542494 operand.effect = isPhiMutatedAfterCreation
4247642495 ? Effect.Capture
4247742496 : Effect.Read;
4247842497 }
4247942498 if (isPhiMutatedAfterCreation &&
4248042499 phi.place.identifier.mutableRange.start === 0) {
42481- const firstInstructionIdOfBlock = (_d = (_c = block.instructions.at(0)) === null || _c === void 0 ? void 0 : _c .id) !== null && _d !== void 0 ? _d : block.terminal.id;
42500+ const firstInstructionIdOfBlock = (_e = (_d = block.instructions.at(0)) === null || _d === void 0 ? void 0 : _d .id) !== null && _e !== void 0 ? _e : block.terminal.id;
4248242501 phi.place.identifier.mutableRange.start = makeInstructionId(firstInstructionIdOfBlock - 1);
4248342502 }
4248442503 }
@@ -42556,15 +42575,15 @@ function inferMutationAliasingRanges(fn, { isFunctionExpression }) {
4255642575 }
4255742576 }
4255842577 for (const lvalue of eachInstructionLValue(instr)) {
42559- const effect = (_e = operandEffects.get(lvalue.identifier.id)) !== null && _e !== void 0 ? _e : Effect.ConditionallyMutate;
42578+ const effect = (_f = operandEffects.get(lvalue.identifier.id)) !== null && _f !== void 0 ? _f : Effect.ConditionallyMutate;
4256042579 lvalue.effect = effect;
4256142580 }
4256242581 for (const operand of eachInstructionValueOperand(instr.value)) {
4256342582 if (operand.identifier.mutableRange.end > instr.id &&
4256442583 operand.identifier.mutableRange.start === 0) {
4256542584 operand.identifier.mutableRange.start = instr.id;
4256642585 }
42567- const effect = (_f = operandEffects.get(operand.identifier.id)) !== null && _f !== void 0 ? _f : Effect.Read;
42586+ const effect = (_g = operandEffects.get(operand.identifier.id)) !== null && _g !== void 0 ? _g : Effect.Read;
4256842587 operand.effect = effect;
4256942588 }
4257042589 if (instr.value.kind === 'StoreContext' &&
@@ -42602,7 +42621,7 @@ function inferMutationAliasingRanges(fn, { isFunctionExpression }) {
4260242621 }
4260342622 for (const into of tracked) {
4260442623 const mutationIndex = index++;
42605- state.mutate(mutationIndex, into.identifier, null, true, MutationKind.Conditional, into.loc, ignoredErrors);
42624+ state.mutate(mutationIndex, into.identifier, null, true, MutationKind.Conditional, into.loc, null, ignoredErrors);
4260642625 for (const from of tracked) {
4260742626 if (from.identifier.id === into.identifier.id ||
4260842627 from.identifier.id === fn.returns.identifier.id) {
@@ -42670,6 +42689,7 @@ class AliasingState {
4267042689 transitive: null,
4267142690 local: null,
4267242691 lastMutated: 0,
42692+ mutationReason: null,
4267342693 value,
4267442694 });
4267542695 }
@@ -42754,7 +42774,8 @@ class AliasingState {
4275442774 }
4275542775 }
4275642776 }
42757- mutate(index, start, end, transitive, startKind, loc, errors) {
42777+ mutate(index, start, end, transitive, startKind, loc, reason, errors) {
42778+ var _a;
4275842779 const seen = new Map();
4275942780 const queue = [{ place: start, transitive, direction: 'backwards', kind: startKind }];
4276042781 while (queue.length !== 0) {
@@ -42768,6 +42789,7 @@ class AliasingState {
4276842789 if (node == null) {
4276942790 continue;
4277042791 }
42792+ (_a = node.mutationReason) !== null && _a !== void 0 ? _a : (node.mutationReason = reason);
4277142793 node.lastMutated = Math.max(node.lastMutated, index);
4277242794 if (end != null) {
4277342795 node.id.mutableRange.end = makeInstructionId(Math.max(node.id.mutableRange.end, end));
0 commit comments