@@ -19518,6 +19518,7 @@ function getFunctionName$2(instrValue, defaultValue) {
19518
19518
}
19519
19519
}
19520
19520
function printAliasingEffect(effect) {
19521
+ var _a;
19521
19522
switch (effect.kind) {
19522
19523
case 'Assign': {
19523
19524
return `Assign ${printPlaceForAliasEffect(effect.into)} = ${printPlaceForAliasEffect(effect.from)}`;
@@ -19576,7 +19577,7 @@ function printAliasingEffect(effect) {
19576
19577
case 'MutateConditionally':
19577
19578
case 'MutateTransitive':
19578
19579
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`)' : ''} `;
19580
19581
}
19581
19582
case 'MutateFrozen': {
19582
19583
return `MutateFrozen ${printPlaceForAliasEffect(effect.place)} reason=${JSON.stringify(effect.error.reason)}`;
@@ -21088,7 +21089,7 @@ class HIRBuilder {
21088
21089
}
21089
21090
}
21090
21091
resolveBinding(node) {
21091
- var _a, _b;
21092
+ var _a, _b, _c ;
21092
21093
if (node.name === 'fbt') {
21093
21094
CompilerError.throwDiagnostic({
21094
21095
severity: ErrorSeverity.Todo,
@@ -21104,6 +21105,21 @@ class HIRBuilder {
21104
21105
],
21105
21106
});
21106
21107
}
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
+ }
21107
21123
const originalName = node.name;
21108
21124
let name = originalName;
21109
21125
let index = 0;
@@ -21121,7 +21137,7 @@ class HIRBuilder {
21121
21137
},
21122
21138
scope: null,
21123
21139
type: makeType(),
21124
- loc: (_b = node.loc) !== null && _b !== void 0 ? _b : GeneratedSource,
21140
+ loc: (_c = node.loc) !== null && _c !== void 0 ? _c : GeneratedSource,
21125
21141
};
21126
21142
__classPrivateFieldGet(this, _HIRBuilder_env, "f").programContext.addNewReference(name);
21127
21143
__classPrivateFieldGet(this, _HIRBuilder_bindings, "f").set(name, { node, identifier });
@@ -42298,7 +42314,7 @@ class RewriteBlockIds extends ReactiveFunctionVisitor {
42298
42314
}
42299
42315
42300
42316
function inferMutationAliasingRanges(fn, { isFunctionExpression }) {
42301
- var _a, _b, _c, _d, _e, _f;
42317
+ var _a, _b, _c, _d, _e, _f, _g ;
42302
42318
const functionEffects = [];
42303
42319
const state = new AliasingState();
42304
42320
const pendingPhis = new Map();
@@ -42365,6 +42381,7 @@ function inferMutationAliasingRanges(fn, { isFunctionExpression }) {
42365
42381
kind: effect.kind === 'MutateTransitive'
42366
42382
? MutationKind.Definite
42367
42383
: MutationKind.Conditional,
42384
+ reason: null,
42368
42385
place: effect.value,
42369
42386
});
42370
42387
}
@@ -42377,6 +42394,7 @@ function inferMutationAliasingRanges(fn, { isFunctionExpression }) {
42377
42394
kind: effect.kind === 'Mutate'
42378
42395
? MutationKind.Definite
42379
42396
: MutationKind.Conditional,
42397
+ reason: effect.kind === 'Mutate' ? ((_a = effect.reason) !== null && _a !== void 0 ? _a : null) : null,
42380
42398
place: effect.value,
42381
42399
});
42382
42400
}
@@ -42418,7 +42436,7 @@ function inferMutationAliasingRanges(fn, { isFunctionExpression }) {
42418
42436
}
42419
42437
}
42420
42438
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);
42422
42440
}
42423
42441
for (const render of renders) {
42424
42442
state.render(render.index, render.place.identifier, errors);
@@ -42443,6 +42461,7 @@ function inferMutationAliasingRanges(fn, { isFunctionExpression }) {
42443
42461
functionEffects.push({
42444
42462
kind: 'Mutate',
42445
42463
value: Object.assign(Object.assign({}, place), { loc: node.local.loc }),
42464
+ reason: node.mutationReason,
42446
42465
});
42447
42466
}
42448
42467
}
@@ -42470,15 +42489,15 @@ function inferMutationAliasingRanges(fn, { isFunctionExpression }) {
42470
42489
for (const phi of block.phis) {
42471
42490
phi.place.effect = Effect.Store;
42472
42491
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);
42474
42493
for (const operand of phi.operands.values()) {
42475
42494
operand.effect = isPhiMutatedAfterCreation
42476
42495
? Effect.Capture
42477
42496
: Effect.Read;
42478
42497
}
42479
42498
if (isPhiMutatedAfterCreation &&
42480
42499
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;
42482
42501
phi.place.identifier.mutableRange.start = makeInstructionId(firstInstructionIdOfBlock - 1);
42483
42502
}
42484
42503
}
@@ -42556,15 +42575,15 @@ function inferMutationAliasingRanges(fn, { isFunctionExpression }) {
42556
42575
}
42557
42576
}
42558
42577
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;
42560
42579
lvalue.effect = effect;
42561
42580
}
42562
42581
for (const operand of eachInstructionValueOperand(instr.value)) {
42563
42582
if (operand.identifier.mutableRange.end > instr.id &&
42564
42583
operand.identifier.mutableRange.start === 0) {
42565
42584
operand.identifier.mutableRange.start = instr.id;
42566
42585
}
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;
42568
42587
operand.effect = effect;
42569
42588
}
42570
42589
if (instr.value.kind === 'StoreContext' &&
@@ -42602,7 +42621,7 @@ function inferMutationAliasingRanges(fn, { isFunctionExpression }) {
42602
42621
}
42603
42622
for (const into of tracked) {
42604
42623
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);
42606
42625
for (const from of tracked) {
42607
42626
if (from.identifier.id === into.identifier.id ||
42608
42627
from.identifier.id === fn.returns.identifier.id) {
@@ -42670,6 +42689,7 @@ class AliasingState {
42670
42689
transitive: null,
42671
42690
local: null,
42672
42691
lastMutated: 0,
42692
+ mutationReason: null,
42673
42693
value,
42674
42694
});
42675
42695
}
@@ -42754,7 +42774,8 @@ class AliasingState {
42754
42774
}
42755
42775
}
42756
42776
}
42757
- mutate(index, start, end, transitive, startKind, loc, errors) {
42777
+ mutate(index, start, end, transitive, startKind, loc, reason, errors) {
42778
+ var _a;
42758
42779
const seen = new Map();
42759
42780
const queue = [{ place: start, transitive, direction: 'backwards', kind: startKind }];
42760
42781
while (queue.length !== 0) {
@@ -42768,6 +42789,7 @@ class AliasingState {
42768
42789
if (node == null) {
42769
42790
continue;
42770
42791
}
42792
+ (_a = node.mutationReason) !== null && _a !== void 0 ? _a : (node.mutationReason = reason);
42771
42793
node.lastMutated = Math.max(node.lastMutated, index);
42772
42794
if (end != null) {
42773
42795
node.id.mutableRange.end = makeInstructionId(Math.max(node.id.mutableRange.end, end));
0 commit comments