babel-plugin-react-compiler 0.0.0-experimental-03b7aef-20240827 → 0.0.0-experimental-4e0eccf-20240830

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -139692,6 +139692,15 @@ function isMutableEffect(effect, location) {
139692
139692
  }
139693
139693
  }
139694
139694
  }
139695
+ function areEqualPaths(a, b) {
139696
+ return (
139697
+ a.length === b.length &&
139698
+ a.every(
139699
+ (item, ix) =>
139700
+ item.property === b[ix].property && item.optional === b[ix].optional
139701
+ )
139702
+ );
139703
+ }
139695
139704
  function makeBlockId(id) {
139696
139705
  CompilerError.invariant(id >= 0 && Number.isInteger(id), {
139697
139706
  reason: 'Expected block id to be a non-negative integer',
@@ -139933,7 +139942,7 @@ function printDependency(dependency) {
139933
139942
  const identifier =
139934
139943
  printIdentifier(dependency.identifier) +
139935
139944
  printType(dependency.identifier.type);
139936
- return `${identifier}${dependency.path.map(prop => `.${prop}`).join('')}`;
139945
+ return `${identifier}${dependency.path.map(token => `${token.optional ? '?.' : '.'}${token.property}`).join('')}`;
139937
139946
  }
139938
139947
  function writeReactiveInstructions(writer, instructions) {
139939
139948
  writer.indented(() => {
@@ -140400,7 +140409,7 @@ function printTerminal(terminal) {
140400
140409
  break;
140401
140410
  }
140402
140411
  case 'branch': {
140403
- value = `[${terminal.id}] Branch (${printPlace(terminal.test)}) then:bb${terminal.consequent} else:bb${terminal.alternate}`;
140412
+ value = `[${terminal.id}] Branch (${printPlace(terminal.test)}) then:bb${terminal.consequent} else:bb${terminal.alternate} fallthrough:bb${terminal.fallthrough}`;
140404
140413
  break;
140405
140414
  }
140406
140415
  case 'logical': {
@@ -140949,7 +140958,7 @@ function printManualMemoDependency(val, nameOnly) {
140949
140958
  ? val.root.value.identifier.name.value
140950
140959
  : printIdentifier(val.root.value.identifier);
140951
140960
  }
140952
- return `${rootStr}${val.path.length > 0 ? '.' : ''}${val.path.join('.')}`;
140961
+ return `${rootStr}${val.path.map(v => `${v.optional ? '?.' : '.'}${v.property}`).join('')}`;
140953
140962
  }
140954
140963
  function printType(type) {
140955
140964
  if (type.kind === 'Type') return '';
@@ -141570,11 +141579,13 @@ function mapTerminalSuccessors(terminal, fn) {
141570
141579
  case 'branch': {
141571
141580
  const consequent = fn(terminal.consequent);
141572
141581
  const alternate = fn(terminal.alternate);
141582
+ const fallthrough = fn(terminal.fallthrough);
141573
141583
  return {
141574
141584
  kind: 'branch',
141575
141585
  test: terminal.test,
141576
141586
  consequent: consequent,
141577
141587
  alternate: alternate,
141588
+ fallthrough: fallthrough,
141578
141589
  id: makeInstructionId(0),
141579
141590
  loc: terminal.loc,
141580
141591
  };
@@ -141786,7 +141797,6 @@ function mapTerminalSuccessors(terminal, fn) {
141786
141797
  function terminalHasFallthrough(terminal) {
141787
141798
  switch (terminal.kind) {
141788
141799
  case 'maybe-throw':
141789
- case 'branch':
141790
141800
  case 'goto':
141791
141801
  case 'return':
141792
141802
  case 'throw':
@@ -141795,6 +141805,7 @@ function terminalHasFallthrough(terminal) {
141795
141805
  terminal.fallthrough;
141796
141806
  return false;
141797
141807
  }
141808
+ case 'branch':
141798
141809
  case 'try':
141799
141810
  case 'do-while':
141800
141811
  case 'for-of':
@@ -144119,6 +144130,7 @@ function lowerStatement(builder, stmtPath, label = null) {
144119
144130
  test: lowerExpressionToTemporary(builder, test),
144120
144131
  consequent: bodyBlock,
144121
144132
  alternate: continuationBlock.id,
144133
+ fallthrough: continuationBlock.id,
144122
144134
  id: makeInstructionId(0),
144123
144135
  loc:
144124
144136
  (_u = stmt.node.loc) !== null && _u !== void 0
@@ -144170,6 +144182,7 @@ function lowerStatement(builder, stmtPath, label = null) {
144170
144182
  test: test,
144171
144183
  consequent: loopBlock,
144172
144184
  alternate: continuationBlock.id,
144185
+ fallthrough: conditionalBlock.id,
144173
144186
  id: makeInstructionId(0),
144174
144187
  loc:
144175
144188
  (_w = stmt.node.loc) !== null && _w !== void 0 ? _w : GeneratedSource,
@@ -144453,6 +144466,7 @@ function lowerStatement(builder, stmtPath, label = null) {
144453
144466
  test: test,
144454
144467
  consequent: loopBlock,
144455
144468
  alternate: continuationBlock.id,
144469
+ fallthrough: conditionalBlock.id,
144456
144470
  id: makeInstructionId(0),
144457
144471
  loc: loc,
144458
144472
  };
@@ -144601,6 +144615,7 @@ function lowerStatement(builder, stmtPath, label = null) {
144601
144615
  (_17 = stmt.node.loc) !== null && _17 !== void 0
144602
144616
  ? _17
144603
144617
  : GeneratedSource,
144618
+ fallthrough: continuationBlock.id,
144604
144619
  },
144605
144620
  continuationBlock
144606
144621
  );
@@ -144688,6 +144703,7 @@ function lowerStatement(builder, stmtPath, label = null) {
144688
144703
  test: test,
144689
144704
  consequent: loopBlock,
144690
144705
  alternate: continuationBlock.id,
144706
+ fallthrough: continuationBlock.id,
144691
144707
  loc:
144692
144708
  (_22 = stmt.node.loc) !== null && _22 !== void 0
144693
144709
  ? _22
@@ -145303,6 +145319,7 @@ function lowerExpression(builder, exprPath) {
145303
145319
  test: Object.assign({}, testPlace),
145304
145320
  consequent: consequentBlock,
145305
145321
  alternate: alternateBlock,
145322
+ fallthrough: continuationBlock.id,
145306
145323
  id: makeInstructionId(0),
145307
145324
  loc: exprLoc,
145308
145325
  },
@@ -145386,6 +145403,7 @@ function lowerExpression(builder, exprPath) {
145386
145403
  test: Object.assign({}, leftPlace),
145387
145404
  consequent: consequent,
145388
145405
  alternate: alternate,
145406
+ fallthrough: continuationBlock.id,
145389
145407
  id: makeInstructionId(0),
145390
145408
  loc: exprLoc,
145391
145409
  },
@@ -146144,6 +146162,7 @@ function lowerOptionalMemberExpression(builder, expr, parentAlternate) {
146144
146162
  test: Object.assign({}, object),
146145
146163
  consequent: consequent.id,
146146
146164
  alternate: alternate,
146165
+ fallthrough: continuationBlock.id,
146147
146166
  id: makeInstructionId(0),
146148
146167
  loc: loc,
146149
146168
  };
@@ -146255,6 +146274,7 @@ function lowerOptionalCallExpression(builder, expr, parentAlternate) {
146255
146274
  test: Object.assign({}, testPlace),
146256
146275
  consequent: consequent.id,
146257
146276
  alternate: alternate,
146277
+ fallthrough: continuationBlock.id,
146258
146278
  id: makeInstructionId(0),
146259
146279
  loc: loc,
146260
146280
  };
@@ -147389,6 +147409,7 @@ function lowerAssignment(
147389
147409
  test: Object.assign({}, test),
147390
147410
  consequent: consequent,
147391
147411
  alternate: alternate,
147412
+ fallthrough: continuationBlock.id,
147392
147413
  id: makeInstructionId(0),
147393
147414
  loc: loc,
147394
147415
  },
@@ -150414,6 +150435,7 @@ const EnvironmentConfigSchema = z.object({
150414
150435
  enableForest: z.boolean().default(false),
150415
150436
  enableUseTypeAnnotations: z.boolean().default(false),
150416
150437
  enableReactiveScopesInHIR: z.boolean().default(true),
150438
+ enableOptionalDependencies: z.boolean().default(true),
150417
150439
  validateHooksUsage: z.boolean().default(true),
150418
150440
  validateRefAccessDuringRender: z.boolean().default(true),
150419
150441
  validateNoSetStateInRender: z.boolean().default(true),
@@ -158557,7 +158579,7 @@ function printDependencyComment(dependency) {
158557
158579
  let name = identifier.name;
158558
158580
  if (dependency.path !== null) {
158559
158581
  for (const path of dependency.path) {
158560
- name += `.${path}`;
158582
+ name += `.${path.property}`;
158561
158583
  }
158562
158584
  }
158563
158585
  return name;
@@ -158583,12 +158605,22 @@ function printDelimitedCommentList(items, finalCompletion) {
158583
158605
  }
158584
158606
  function codegenDependency(cx, dependency) {
158585
158607
  let object = convertIdentifier(dependency.identifier);
158586
- if (dependency.path !== null) {
158608
+ if (dependency.path.length !== 0) {
158609
+ const hasOptional = dependency.path.some(path => path.optional);
158587
158610
  for (const path of dependency.path) {
158588
- object = t__namespace.memberExpression(
158589
- object,
158590
- t__namespace.identifier(path)
158591
- );
158611
+ if (hasOptional) {
158612
+ object = t__namespace.optionalMemberExpression(
158613
+ object,
158614
+ t__namespace.identifier(path.property),
158615
+ false,
158616
+ path.optional
158617
+ );
158618
+ } else {
158619
+ object = t__namespace.memberExpression(
158620
+ object,
158621
+ t__namespace.identifier(path.property)
158622
+ );
158623
+ }
158592
158624
  }
158593
158625
  }
158594
158626
  return object;
@@ -160202,9 +160234,6 @@ function areEqualDependencies(a, b) {
160202
160234
  }
160203
160235
  return true;
160204
160236
  }
160205
- function areEqualPaths(a, b) {
160206
- return a.length === b.length && a.every((item, ix) => item === b[ix]);
160207
- }
160208
160237
  function scopeIsEligibleForMerging(scopeBlock) {
160209
160238
  if (scopeBlock.scope.dependencies.size === 0) {
160210
160239
  return true;
@@ -160871,47 +160900,37 @@ class Empty {
160871
160900
  const EMPTY = new Empty();
160872
160901
  var _ReactiveScopeDependencyTree_instances,
160873
160902
  _ReactiveScopeDependencyTree_roots,
160874
- _ReactiveScopeDependencyTree_getOrCreateRoot;
160903
+ _ReactiveScopeDependencyTree_getOrCreateRoot,
160904
+ _ReactiveScopeDependencyTree_debugImpl;
160875
160905
  class ReactiveScopeDependencyTree {
160876
160906
  constructor() {
160877
160907
  _ReactiveScopeDependencyTree_instances.add(this);
160878
160908
  _ReactiveScopeDependencyTree_roots.set(this, new Map());
160879
160909
  }
160880
160910
  add(dep, inConditional) {
160881
- const {path: path, optionalPath: optionalPath} = dep;
160911
+ const {path: path} = dep;
160882
160912
  let currNode = __classPrivateFieldGet(
160883
160913
  this,
160884
160914
  _ReactiveScopeDependencyTree_instances,
160885
160915
  'm',
160886
160916
  _ReactiveScopeDependencyTree_getOrCreateRoot
160887
160917
  ).call(this, dep.identifier);
160888
- const accessType = inConditional
160889
- ? PropertyAccessType.ConditionalAccess
160890
- : PropertyAccessType.UnconditionalAccess;
160891
- for (const property of path) {
160892
- let currChild = getOrMakeProperty(currNode, property);
160918
+ for (const item of path) {
160919
+ let currChild = getOrMakeProperty(currNode, item.property);
160920
+ const accessType = inConditional
160921
+ ? PropertyAccessType.ConditionalAccess
160922
+ : item.optional
160923
+ ? PropertyAccessType.OptionalAccess
160924
+ : PropertyAccessType.UnconditionalAccess;
160893
160925
  currChild.accessType = merge(currChild.accessType, accessType);
160894
160926
  currNode = currChild;
160895
160927
  }
160896
- if (optionalPath.length === 0) {
160897
- const depType = inConditional
160898
- ? PropertyAccessType.ConditionalDependency
160928
+ const depType = inConditional
160929
+ ? PropertyAccessType.ConditionalDependency
160930
+ : isOptional(currNode.accessType)
160931
+ ? PropertyAccessType.OptionalDependency
160899
160932
  : PropertyAccessType.UnconditionalDependency;
160900
- currNode.accessType = merge(currNode.accessType, depType);
160901
- } else {
160902
- for (const property of optionalPath) {
160903
- let currChild = getOrMakeProperty(currNode, property);
160904
- currChild.accessType = merge(
160905
- currChild.accessType,
160906
- PropertyAccessType.ConditionalAccess
160907
- );
160908
- currNode = currChild;
160909
- }
160910
- currNode.accessType = merge(
160911
- currNode.accessType,
160912
- PropertyAccessType.ConditionalDependency
160913
- );
160914
- }
160933
+ currNode.accessType = merge(currNode.accessType, depType);
160915
160934
  }
160916
160935
  deriveMinimalDependencies() {
160917
160936
  const results = new Set();
@@ -160920,10 +160939,12 @@ class ReactiveScopeDependencyTree {
160920
160939
  _ReactiveScopeDependencyTree_roots,
160921
160940
  'f'
160922
160941
  ).entries()) {
160923
- const deps = deriveMinimalDependenciesInSubtree(rootNode);
160942
+ const deps = deriveMinimalDependenciesInSubtree(rootNode, null);
160924
160943
  CompilerError.invariant(
160925
160944
  deps.every(
160926
- dep => dep.accessType === PropertyAccessType.UnconditionalDependency
160945
+ dep =>
160946
+ dep.accessType === PropertyAccessType.UnconditionalDependency ||
160947
+ dep.accessType == PropertyAccessType.OptionalDependency
160927
160948
  ),
160928
160949
  {
160929
160950
  reason:
@@ -161012,6 +161033,24 @@ class ReactiveScopeDependencyTree {
161012
161033
  }
161013
161034
  return res.flat().join('\n');
161014
161035
  }
161036
+ debug() {
161037
+ const buf = [`tree() [`];
161038
+ for (const [rootId, rootNode] of __classPrivateFieldGet(
161039
+ this,
161040
+ _ReactiveScopeDependencyTree_roots,
161041
+ 'f'
161042
+ )) {
161043
+ buf.push(`${printIdentifier(rootId)} (${rootNode.accessType}):`);
161044
+ __classPrivateFieldGet(
161045
+ this,
161046
+ _ReactiveScopeDependencyTree_instances,
161047
+ 'm',
161048
+ _ReactiveScopeDependencyTree_debugImpl
161049
+ ).call(this, buf, rootNode, 1);
161050
+ }
161051
+ buf.push(']');
161052
+ return buf.length > 2 ? buf.join('\n') : buf.join('');
161053
+ }
161015
161054
  }
161016
161055
  (_ReactiveScopeDependencyTree_roots = new WeakMap()),
161017
161056
  (_ReactiveScopeDependencyTree_instances = new WeakSet()),
@@ -161034,12 +161073,28 @@ class ReactiveScopeDependencyTree {
161034
161073
  ).set(identifier, rootNode);
161035
161074
  }
161036
161075
  return rootNode;
161076
+ }),
161077
+ (_ReactiveScopeDependencyTree_debugImpl =
161078
+ function _ReactiveScopeDependencyTree_debugImpl(buf, node, depth = 0) {
161079
+ for (const [property, childNode] of node.properties) {
161080
+ buf.push(
161081
+ `${' '.repeat(depth)}.${property} (${childNode.accessType}):`
161082
+ );
161083
+ __classPrivateFieldGet(
161084
+ this,
161085
+ _ReactiveScopeDependencyTree_instances,
161086
+ 'm',
161087
+ _ReactiveScopeDependencyTree_debugImpl
161088
+ ).call(this, buf, childNode, depth + 1);
161089
+ }
161037
161090
  });
161038
161091
  var PropertyAccessType;
161039
161092
  (function (PropertyAccessType) {
161040
161093
  PropertyAccessType['ConditionalAccess'] = 'ConditionalAccess';
161094
+ PropertyAccessType['OptionalAccess'] = 'OptionalAccess';
161041
161095
  PropertyAccessType['UnconditionalAccess'] = 'UnconditionalAccess';
161042
161096
  PropertyAccessType['ConditionalDependency'] = 'ConditionalDependency';
161097
+ PropertyAccessType['OptionalDependency'] = 'OptionalDependency';
161043
161098
  PropertyAccessType['UnconditionalDependency'] = 'UnconditionalDependency';
161044
161099
  })(PropertyAccessType || (PropertyAccessType = {}));
161045
161100
  const MIN_ACCESS_TYPE = PropertyAccessType.ConditionalAccess;
@@ -161052,19 +161107,33 @@ function isUnconditional(access) {
161052
161107
  function isDependency(access) {
161053
161108
  return (
161054
161109
  access === PropertyAccessType.ConditionalDependency ||
161110
+ access === PropertyAccessType.OptionalDependency ||
161055
161111
  access === PropertyAccessType.UnconditionalDependency
161056
161112
  );
161057
161113
  }
161114
+ function isOptional(access) {
161115
+ return (
161116
+ access === PropertyAccessType.OptionalAccess ||
161117
+ access === PropertyAccessType.OptionalDependency
161118
+ );
161119
+ }
161058
161120
  function merge(access1, access2) {
161059
161121
  const resultIsUnconditional =
161060
161122
  isUnconditional(access1) || isUnconditional(access2);
161061
161123
  const resultIsDependency = isDependency(access1) || isDependency(access2);
161124
+ const resultIsOptional = isOptional(access1) || isOptional(access2);
161062
161125
  if (resultIsUnconditional) {
161063
161126
  if (resultIsDependency) {
161064
161127
  return PropertyAccessType.UnconditionalDependency;
161065
161128
  } else {
161066
161129
  return PropertyAccessType.UnconditionalAccess;
161067
161130
  }
161131
+ } else if (resultIsOptional) {
161132
+ if (resultIsDependency) {
161133
+ return PropertyAccessType.OptionalDependency;
161134
+ } else {
161135
+ return PropertyAccessType.OptionalAccess;
161136
+ }
161068
161137
  } else {
161069
161138
  if (resultIsDependency) {
161070
161139
  return PropertyAccessType.ConditionalDependency;
@@ -161073,37 +161142,80 @@ function merge(access1, access2) {
161073
161142
  }
161074
161143
  }
161075
161144
  }
161076
- const promoteUncondResult = [
161077
- {relativePath: [], accessType: PropertyAccessType.UnconditionalDependency},
161078
- ];
161079
- const promoteCondResult = [
161080
- {relativePath: [], accessType: PropertyAccessType.ConditionalDependency},
161081
- ];
161082
- function deriveMinimalDependenciesInSubtree(dep) {
161145
+ function promoteResult(accessType, path) {
161146
+ const result = {relativePath: [], accessType: accessType};
161147
+ if (path !== null) {
161148
+ result.relativePath.push(path);
161149
+ }
161150
+ return [result];
161151
+ }
161152
+ function prependPath(results, path) {
161153
+ if (path === null) {
161154
+ return results;
161155
+ }
161156
+ return results.map(result => ({
161157
+ accessType: result.accessType,
161158
+ relativePath: [path, ...result.relativePath],
161159
+ }));
161160
+ }
161161
+ function deriveMinimalDependenciesInSubtree(dep, property) {
161083
161162
  const results = [];
161084
161163
  for (const [childName, childNode] of dep.properties) {
161085
- const childResult = deriveMinimalDependenciesInSubtree(childNode).map(
161086
- ({relativePath: relativePath, accessType: accessType}) => ({
161087
- relativePath: [childName, ...relativePath],
161088
- accessType: accessType,
161089
- })
161164
+ const childResult = deriveMinimalDependenciesInSubtree(
161165
+ childNode,
161166
+ childName
161090
161167
  );
161091
161168
  results.push(...childResult);
161092
161169
  }
161093
161170
  switch (dep.accessType) {
161094
161171
  case PropertyAccessType.UnconditionalDependency: {
161095
- return promoteUncondResult;
161172
+ return promoteResult(
161173
+ PropertyAccessType.UnconditionalDependency,
161174
+ property !== null ? {property: property, optional: false} : null
161175
+ );
161096
161176
  }
161097
161177
  case PropertyAccessType.UnconditionalAccess: {
161098
161178
  if (
161099
161179
  results.every(
161100
161180
  ({accessType: accessType}) =>
161101
- accessType === PropertyAccessType.UnconditionalDependency
161181
+ accessType === PropertyAccessType.UnconditionalDependency ||
161182
+ accessType === PropertyAccessType.OptionalDependency
161102
161183
  )
161103
161184
  ) {
161104
- return results;
161185
+ return prependPath(
161186
+ results,
161187
+ property !== null ? {property: property, optional: false} : null
161188
+ );
161105
161189
  } else {
161106
- return promoteUncondResult;
161190
+ return promoteResult(
161191
+ PropertyAccessType.UnconditionalDependency,
161192
+ property !== null ? {property: property, optional: false} : null
161193
+ );
161194
+ }
161195
+ }
161196
+ case PropertyAccessType.OptionalDependency: {
161197
+ return promoteResult(
161198
+ PropertyAccessType.OptionalDependency,
161199
+ property !== null ? {property: property, optional: true} : null
161200
+ );
161201
+ }
161202
+ case PropertyAccessType.OptionalAccess: {
161203
+ if (
161204
+ results.every(
161205
+ ({accessType: accessType}) =>
161206
+ accessType === PropertyAccessType.UnconditionalDependency ||
161207
+ accessType === PropertyAccessType.OptionalDependency
161208
+ )
161209
+ ) {
161210
+ return prependPath(
161211
+ results,
161212
+ property !== null ? {property: property, optional: true} : null
161213
+ );
161214
+ } else {
161215
+ return promoteResult(
161216
+ PropertyAccessType.OptionalDependency,
161217
+ property !== null ? {property: property, optional: true} : null
161218
+ );
161107
161219
  }
161108
161220
  }
161109
161221
  case PropertyAccessType.ConditionalAccess:
@@ -161114,9 +161226,15 @@ function deriveMinimalDependenciesInSubtree(dep) {
161114
161226
  accessType === PropertyAccessType.ConditionalDependency
161115
161227
  )
161116
161228
  ) {
161117
- return promoteCondResult;
161229
+ return promoteResult(
161230
+ PropertyAccessType.ConditionalDependency,
161231
+ property !== null ? {property: property, optional: true} : null
161232
+ );
161118
161233
  } else {
161119
- return promoteUncondResult;
161234
+ return promoteResult(
161235
+ PropertyAccessType.UnconditionalDependency,
161236
+ property !== null ? {property: property, optional: true} : null
161237
+ );
161120
161238
  }
161121
161239
  }
161122
161240
  default: {
@@ -161261,11 +161379,7 @@ function propagateScopeDependencies(fn) {
161261
161379
  });
161262
161380
  }
161263
161381
  }
161264
- visitReactiveFunction(
161265
- fn,
161266
- new PropagationVisitor(fn.env.config.enableTreatFunctionDepsAsConditional),
161267
- context
161268
- );
161382
+ visitReactiveFunction(fn, new PropagationVisitor(fn.env), context);
161269
161383
  }
161270
161384
  class FindPromotedTemporaries extends ReactiveFunctionVisitor {
161271
161385
  constructor() {
@@ -161634,13 +161748,13 @@ class Context {
161634
161748
  ? _a
161635
161749
  : place;
161636
161750
  }
161637
- declareProperty(lvalue, object, property) {
161751
+ declareProperty(lvalue, object, property, optional) {
161638
161752
  const nextDependency = __classPrivateFieldGet(
161639
161753
  this,
161640
161754
  _Context_instances,
161641
161755
  'm',
161642
161756
  _Context_getProperty
161643
- ).call(this, object, property, false);
161757
+ ).call(this, object, property, optional);
161644
161758
  __classPrivateFieldGet(this, _Context_properties, 'f').set(
161645
161759
  lvalue.identifier,
161646
161760
  nextDependency
@@ -161654,11 +161768,7 @@ class Context {
161654
161768
  }
161655
161769
  visitOperand(place) {
161656
161770
  const resolved = this.resolveTemporary(place);
161657
- let dependency = {
161658
- identifier: resolved.identifier,
161659
- path: [],
161660
- optionalPath: [],
161661
- };
161771
+ let dependency = {identifier: resolved.identifier, path: []};
161662
161772
  if (resolved.identifier.name === null) {
161663
161773
  const propertyDependency = __classPrivateFieldGet(
161664
161774
  this,
@@ -161671,13 +161781,13 @@ class Context {
161671
161781
  }
161672
161782
  this.visitDependency(dependency);
161673
161783
  }
161674
- visitProperty(object, property) {
161784
+ visitProperty(object, property, optional) {
161675
161785
  const nextDependency = __classPrivateFieldGet(
161676
161786
  this,
161677
161787
  _Context_instances,
161678
161788
  'm',
161679
161789
  _Context_getProperty
161680
- ).call(this, object, property, false);
161790
+ ).call(this, object, property, optional);
161681
161791
  this.visitDependency(nextDependency);
161682
161792
  }
161683
161793
  visitDependency(maybeDependency) {
@@ -161795,7 +161905,7 @@ class Context {
161795
161905
  (_Context_getProperty = function _Context_getProperty(
161796
161906
  object,
161797
161907
  property,
161798
- isConditional
161908
+ optional
161799
161909
  ) {
161800
161910
  const resolvedObject = this.resolveTemporary(object);
161801
161911
  const resolvedDependency = __classPrivateFieldGet(
@@ -161805,34 +161915,25 @@ class Context {
161805
161915
  ).get(resolvedObject.identifier);
161806
161916
  let objectDependency;
161807
161917
  if (resolvedDependency === undefined) {
161808
- objectDependency = {
161809
- identifier: resolvedObject.identifier,
161810
- path: [],
161811
- optionalPath: [],
161812
- };
161918
+ objectDependency = {identifier: resolvedObject.identifier, path: []};
161813
161919
  } else {
161814
161920
  objectDependency = {
161815
161921
  identifier: resolvedDependency.identifier,
161816
161922
  path: [...resolvedDependency.path],
161817
- optionalPath: [...resolvedDependency.optionalPath],
161818
161923
  };
161819
161924
  }
161820
- if (objectDependency.optionalPath.length > 0) {
161821
- objectDependency.optionalPath.push(property);
161822
- } else if (isConditional) {
161823
- objectDependency.optionalPath.push(property);
161824
- } else {
161825
- objectDependency.path.push(property);
161826
- }
161925
+ objectDependency.path.push({property: property, optional: optional});
161827
161926
  return objectDependency;
161828
161927
  }),
161829
161928
  (_Context_checkValidDependency = function _Context_checkValidDependency(
161830
161929
  maybeDependency
161831
161930
  ) {
161832
- var _a, _b, _c;
161931
+ var _a, _b, _c, _d;
161833
161932
  if (
161834
161933
  isUseRefType(maybeDependency.identifier) &&
161835
- maybeDependency.path.at(0) === 'current'
161934
+ ((_a = maybeDependency.path.at(0)) === null || _a === void 0
161935
+ ? void 0
161936
+ : _a.property) === 'current'
161836
161937
  ) {
161837
161938
  return false;
161838
161939
  }
@@ -161844,25 +161945,25 @@ class Context {
161844
161945
  }
161845
161946
  const identifier = maybeDependency.identifier;
161846
161947
  const currentDeclaration =
161847
- (_a = __classPrivateFieldGet(this, _Context_reassignments, 'f').get(
161948
+ (_b = __classPrivateFieldGet(this, _Context_reassignments, 'f').get(
161848
161949
  identifier
161849
- )) !== null && _a !== void 0
161850
- ? _a
161950
+ )) !== null && _b !== void 0
161951
+ ? _b
161851
161952
  : __classPrivateFieldGet(this, _Context_declarations, 'f').get(
161852
161953
  identifier.declarationId
161853
161954
  );
161854
161955
  const currentScope =
161855
- (_b = this.currentScope.value) === null || _b === void 0
161956
+ (_c = this.currentScope.value) === null || _c === void 0
161856
161957
  ? void 0
161857
- : _b.value;
161958
+ : _c.value;
161858
161959
  return (
161859
161960
  currentScope != null &&
161860
161961
  currentDeclaration !== undefined &&
161861
161962
  currentDeclaration.id < currentScope.range.start &&
161862
161963
  (currentDeclaration.scope == null ||
161863
- ((_c = currentDeclaration.scope.value) === null || _c === void 0
161964
+ ((_d = currentDeclaration.scope.value) === null || _d === void 0
161864
161965
  ? void 0
161865
- : _c.value) !== currentScope)
161966
+ : _d.value) !== currentScope)
161866
161967
  );
161867
161968
  }),
161868
161969
  (_Context_isScopeActive = function _Context_isScopeActive(scope) {
@@ -161874,11 +161975,9 @@ class Context {
161874
161975
  );
161875
161976
  });
161876
161977
  class PropagationVisitor extends ReactiveFunctionVisitor {
161877
- constructor(enableTreatFunctionDepsAsConditional) {
161978
+ constructor(env) {
161878
161979
  super();
161879
- this.enableTreatFunctionDepsAsConditional = false;
161880
- this.enableTreatFunctionDepsAsConditional =
161881
- enableTreatFunctionDepsAsConditional;
161980
+ this.env = env;
161882
161981
  }
161883
161982
  visitScope(scope, context) {
161884
161983
  const scopeDependencies = context.enter(scope.scope, () => {
@@ -161911,39 +162010,177 @@ class PropagationVisitor extends ReactiveFunctionVisitor {
161911
162010
  }
161912
162011
  context.declare(lvalue.identifier, {id: id, scope: context.currentScope});
161913
162012
  }
161914
- visitReactiveValue(context, id, value) {
162013
+ extractOptionalProperty(context, optionalValue, lvalue) {
162014
+ const sequence = optionalValue.value;
162015
+ CompilerError.invariant(sequence.kind === 'SequenceExpression', {
162016
+ reason: 'Expected OptionalExpression value to be a SequenceExpression',
162017
+ description: `Found a \`${sequence.kind}\``,
162018
+ loc: sequence.loc,
162019
+ });
162020
+ if (
162021
+ sequence.instructions.length === 1 &&
162022
+ sequence.instructions[0].lvalue !== null &&
162023
+ sequence.instructions[0].value.kind === 'LoadLocal' &&
162024
+ sequence.instructions[0].value.place.identifier.name !== null &&
162025
+ !context.isUsedOutsideDeclaringScope(sequence.instructions[0].lvalue) &&
162026
+ sequence.value.kind === 'SequenceExpression' &&
162027
+ sequence.value.instructions.length === 1 &&
162028
+ sequence.value.instructions[0].value.kind === 'PropertyLoad' &&
162029
+ sequence.value.instructions[0].value.object.identifier.id ===
162030
+ sequence.instructions[0].lvalue.identifier.id &&
162031
+ sequence.value.instructions[0].lvalue !== null &&
162032
+ sequence.value.value.kind === 'LoadLocal' &&
162033
+ sequence.value.value.place.identifier.id ===
162034
+ sequence.value.instructions[0].lvalue.identifier.id
162035
+ ) {
162036
+ context.declareTemporary(
162037
+ sequence.instructions[0].lvalue,
162038
+ sequence.instructions[0].value.place
162039
+ );
162040
+ const propertyLoad = sequence.value.instructions[0].value;
162041
+ return {
162042
+ lvalue: lvalue,
162043
+ object: propertyLoad.object,
162044
+ property: propertyLoad.property,
162045
+ optional: optionalValue.optional,
162046
+ };
162047
+ }
162048
+ if (
162049
+ sequence.instructions.length === 1 &&
162050
+ sequence.instructions[0].lvalue !== null &&
162051
+ sequence.instructions[0].value.kind === 'SequenceExpression' &&
162052
+ sequence.instructions[0].value.instructions.length === 1 &&
162053
+ sequence.instructions[0].value.instructions[0].lvalue !== null &&
162054
+ sequence.instructions[0].value.instructions[0].value.kind ===
162055
+ 'LoadLocal' &&
162056
+ sequence.instructions[0].value.instructions[0].value.place.identifier
162057
+ .name !== null &&
162058
+ !context.isUsedOutsideDeclaringScope(
162059
+ sequence.instructions[0].value.instructions[0].lvalue
162060
+ ) &&
162061
+ sequence.instructions[0].value.value.kind === 'PropertyLoad' &&
162062
+ sequence.instructions[0].value.value.object.identifier.id ===
162063
+ sequence.instructions[0].value.instructions[0].lvalue.identifier.id &&
162064
+ sequence.value.kind === 'SequenceExpression' &&
162065
+ sequence.value.instructions.length === 1 &&
162066
+ sequence.value.instructions[0].lvalue !== null &&
162067
+ sequence.value.instructions[0].value.kind === 'PropertyLoad' &&
162068
+ sequence.value.instructions[0].value.object.identifier.id ===
162069
+ sequence.instructions[0].lvalue.identifier.id &&
162070
+ sequence.value.value.kind === 'LoadLocal' &&
162071
+ sequence.value.value.place.identifier.id ===
162072
+ sequence.value.instructions[0].lvalue.identifier.id
162073
+ ) {
162074
+ context.declareTemporary(
162075
+ sequence.instructions[0].value.instructions[0].lvalue,
162076
+ sequence.instructions[0].value.instructions[0].value.place
162077
+ );
162078
+ context.declareProperty(
162079
+ sequence.instructions[0].lvalue,
162080
+ sequence.instructions[0].value.value.object,
162081
+ sequence.instructions[0].value.value.property,
162082
+ false
162083
+ );
162084
+ const propertyLoad = sequence.value.instructions[0].value;
162085
+ return {
162086
+ lvalue: lvalue,
162087
+ object: propertyLoad.object,
162088
+ property: propertyLoad.property,
162089
+ optional: optionalValue.optional,
162090
+ };
162091
+ }
162092
+ if (
162093
+ sequence.instructions.length === 1 &&
162094
+ sequence.instructions[0].value.kind === 'SequenceExpression' &&
162095
+ sequence.instructions[0].value.instructions.length === 1 &&
162096
+ sequence.instructions[0].value.instructions[0].lvalue !== null &&
162097
+ sequence.instructions[0].value.instructions[0].value.kind ===
162098
+ 'OptionalExpression' &&
162099
+ sequence.instructions[0].value.value.kind === 'LoadLocal' &&
162100
+ sequence.instructions[0].value.value.place.identifier.id ===
162101
+ sequence.instructions[0].value.instructions[0].lvalue.identifier.id &&
162102
+ sequence.value.kind === 'SequenceExpression' &&
162103
+ sequence.value.instructions.length === 1 &&
162104
+ sequence.value.instructions[0].lvalue !== null &&
162105
+ sequence.value.instructions[0].value.kind === 'PropertyLoad' &&
162106
+ sequence.value.instructions[0].value.object.identifier.id ===
162107
+ sequence.instructions[0].value.value.place.identifier.id &&
162108
+ sequence.value.value.kind === 'LoadLocal' &&
162109
+ sequence.value.value.place.identifier.id ===
162110
+ sequence.value.instructions[0].lvalue.identifier.id
162111
+ ) {
162112
+ const {lvalue: innerLvalue, value: innerOptional} =
162113
+ sequence.instructions[0].value.instructions[0];
162114
+ const innerProperty = this.extractOptionalProperty(
162115
+ context,
162116
+ innerOptional,
162117
+ innerLvalue
162118
+ );
162119
+ if (innerProperty === null) {
162120
+ return null;
162121
+ }
162122
+ context.declareProperty(
162123
+ innerProperty.lvalue,
162124
+ innerProperty.object,
162125
+ innerProperty.property,
162126
+ innerProperty.optional
162127
+ );
162128
+ const propertyLoad = sequence.value.instructions[0].value;
162129
+ return {
162130
+ lvalue: lvalue,
162131
+ object: propertyLoad.object,
162132
+ property: propertyLoad.property,
162133
+ optional: optionalValue.optional,
162134
+ };
162135
+ }
162136
+ return null;
162137
+ }
162138
+ visitOptionalExpression(context, id, value, lvalue) {
162139
+ if (
162140
+ lvalue !== null &&
162141
+ value.optional &&
162142
+ this.env.config.enableOptionalDependencies
162143
+ ) {
162144
+ const inner = this.extractOptionalProperty(context, value, lvalue);
162145
+ if (inner !== null) {
162146
+ context.visitProperty(inner.object, inner.property, inner.optional);
162147
+ return;
162148
+ }
162149
+ }
162150
+ const inner = value.value;
162151
+ CompilerError.invariant(inner.kind === 'SequenceExpression', {
162152
+ reason: 'Expected OptionalExpression value to be a SequenceExpression',
162153
+ description: `Found a \`${value.kind}\``,
162154
+ loc: value.loc,
162155
+ suggestions: null,
162156
+ });
162157
+ for (const instr of inner.instructions) {
162158
+ this.visitInstruction(instr, context);
162159
+ }
162160
+ context.enterConditional(() => {
162161
+ this.visitReactiveValue(context, id, inner.value, null);
162162
+ });
162163
+ }
162164
+ visitReactiveValue(context, id, value, lvalue) {
161915
162165
  switch (value.kind) {
161916
162166
  case 'OptionalExpression': {
161917
- const inner = value.value;
161918
- CompilerError.invariant(inner.kind === 'SequenceExpression', {
161919
- reason:
161920
- 'Expected OptionalExpression value to be a SequenceExpression',
161921
- description: `Found a \`${value.kind}\``,
161922
- loc: value.loc,
161923
- suggestions: null,
161924
- });
161925
- for (const instr of inner.instructions) {
161926
- this.visitInstruction(instr, context);
161927
- }
161928
- context.enterConditional(() => {
161929
- this.visitReactiveValue(context, id, inner.value);
161930
- });
162167
+ this.visitOptionalExpression(context, id, value, lvalue);
161931
162168
  break;
161932
162169
  }
161933
162170
  case 'LogicalExpression': {
161934
- this.visitReactiveValue(context, id, value.left);
162171
+ this.visitReactiveValue(context, id, value.left, null);
161935
162172
  context.enterConditional(() => {
161936
- this.visitReactiveValue(context, id, value.right);
162173
+ this.visitReactiveValue(context, id, value.right, null);
161937
162174
  });
161938
162175
  break;
161939
162176
  }
161940
162177
  case 'ConditionalExpression': {
161941
- this.visitReactiveValue(context, id, value.test);
162178
+ this.visitReactiveValue(context, id, value.test, null);
161942
162179
  const consequentDeps = context.enterConditional(() => {
161943
- this.visitReactiveValue(context, id, value.consequent);
162180
+ this.visitReactiveValue(context, id, value.consequent, null);
161944
162181
  });
161945
162182
  const alternateDeps = context.enterConditional(() => {
161946
- this.visitReactiveValue(context, id, value.alternate);
162183
+ this.visitReactiveValue(context, id, value.alternate, null);
161947
162184
  });
161948
162185
  context.promoteDepsFromExhaustiveConditionals([
161949
162186
  consequentDeps,
@@ -161959,7 +162196,7 @@ class PropagationVisitor extends ReactiveFunctionVisitor {
161959
162196
  break;
161960
162197
  }
161961
162198
  case 'FunctionExpression': {
161962
- if (this.enableTreatFunctionDepsAsConditional) {
162199
+ if (this.env.config.enableTreatFunctionDepsAsConditional) {
161963
162200
  context.enterConditional(() => {
161964
162201
  for (const operand of eachInstructionValueOperand(value)) {
161965
162202
  context.visitOperand(operand);
@@ -162000,9 +162237,9 @@ class PropagationVisitor extends ReactiveFunctionVisitor {
162000
162237
  }
162001
162238
  } else if (value.kind === 'PropertyLoad') {
162002
162239
  if (lvalue !== null && !context.isUsedOutsideDeclaringScope(lvalue)) {
162003
- context.declareProperty(lvalue, value.object, value.property);
162240
+ context.declareProperty(lvalue, value.object, value.property, false);
162004
162241
  } else {
162005
- context.visitProperty(value.object, value.property);
162242
+ context.visitProperty(value.object, value.property, false);
162006
162243
  }
162007
162244
  } else if (value.kind === 'StoreLocal') {
162008
162245
  context.visitOperand(value.value);
@@ -162033,7 +162270,7 @@ class PropagationVisitor extends ReactiveFunctionVisitor {
162033
162270
  });
162034
162271
  }
162035
162272
  } else {
162036
- this.visitReactiveValue(context, id, value);
162273
+ this.visitReactiveValue(context, id, value, lvalue);
162037
162274
  }
162038
162275
  }
162039
162276
  enterTerminal(stmt, context) {
@@ -162079,25 +162316,30 @@ class PropagationVisitor extends ReactiveFunctionVisitor {
162079
162316
  break;
162080
162317
  }
162081
162318
  case 'for': {
162082
- this.visitReactiveValue(context, terminal.id, terminal.init);
162083
- this.visitReactiveValue(context, terminal.id, terminal.test);
162319
+ this.visitReactiveValue(context, terminal.id, terminal.init, null);
162320
+ this.visitReactiveValue(context, terminal.id, terminal.test, null);
162084
162321
  context.enterConditional(() => {
162085
162322
  this.visitBlock(terminal.loop, context);
162086
162323
  if (terminal.update !== null) {
162087
- this.visitReactiveValue(context, terminal.id, terminal.update);
162324
+ this.visitReactiveValue(
162325
+ context,
162326
+ terminal.id,
162327
+ terminal.update,
162328
+ null
162329
+ );
162088
162330
  }
162089
162331
  });
162090
162332
  break;
162091
162333
  }
162092
162334
  case 'for-of': {
162093
- this.visitReactiveValue(context, terminal.id, terminal.init);
162335
+ this.visitReactiveValue(context, terminal.id, terminal.init, null);
162094
162336
  context.enterConditional(() => {
162095
162337
  this.visitBlock(terminal.loop, context);
162096
162338
  });
162097
162339
  break;
162098
162340
  }
162099
162341
  case 'for-in': {
162100
- this.visitReactiveValue(context, terminal.id, terminal.init);
162342
+ this.visitReactiveValue(context, terminal.id, terminal.init, null);
162101
162343
  context.enterConditional(() => {
162102
162344
  this.visitBlock(terminal.loop, context);
162103
162345
  });
@@ -162106,12 +162348,12 @@ class PropagationVisitor extends ReactiveFunctionVisitor {
162106
162348
  case 'do-while': {
162107
162349
  this.visitBlock(terminal.loop, context);
162108
162350
  context.enterConditional(() => {
162109
- this.visitReactiveValue(context, terminal.id, terminal.test);
162351
+ this.visitReactiveValue(context, terminal.id, terminal.test, null);
162110
162352
  });
162111
162353
  break;
162112
162354
  }
162113
162355
  case 'while': {
162114
- this.visitReactiveValue(context, terminal.id, terminal.test);
162356
+ this.visitReactiveValue(context, terminal.id, terminal.test, null);
162115
162357
  context.enterConditional(() => {
162116
162358
  this.visitBlock(terminal.loop, context);
162117
162359
  });
@@ -165510,7 +165752,7 @@ function infer(loweredFunc, state, context) {
165510
165752
  function isMutatedOrReassigned(id) {
165511
165753
  return id.mutableRange.end > id.mutableRange.start;
165512
165754
  }
165513
- function collectMaybeMemoDependencies(value, maybeDeps) {
165755
+ function collectMaybeMemoDependencies(value, maybeDeps, optional) {
165514
165756
  var _a;
165515
165757
  switch (value.kind) {
165516
165758
  case 'LoadGlobal': {
@@ -165522,7 +165764,13 @@ function collectMaybeMemoDependencies(value, maybeDeps) {
165522
165764
  case 'PropertyLoad': {
165523
165765
  const object = maybeDeps.get(value.object.identifier.id);
165524
165766
  if (object != null) {
165525
- return {root: object.root, path: [...object.path, value.property]};
165767
+ return {
165768
+ root: object.root,
165769
+ path: [
165770
+ ...object.path,
165771
+ {property: value.property, optional: optional},
165772
+ ],
165773
+ };
165526
165774
  }
165527
165775
  break;
165528
165776
  }
@@ -165595,7 +165843,11 @@ function collectTemporaries(instr, env, sidemap) {
165595
165843
  break;
165596
165844
  }
165597
165845
  }
165598
- const maybeDep = collectMaybeMemoDependencies(value, sidemap.maybeDeps);
165846
+ const maybeDep = collectMaybeMemoDependencies(
165847
+ value,
165848
+ sidemap.maybeDeps,
165849
+ sidemap.optionals.has(lvalue.identifier.id)
165850
+ );
165599
165851
  if (maybeDep != null) {
165600
165852
  sidemap.maybeDeps.set(lvalue.identifier.id, maybeDep);
165601
165853
  }
@@ -165701,12 +165953,14 @@ function dropManualMemoization(func) {
165701
165953
  func.env.config.validatePreserveExistingMemoizationGuarantees ||
165702
165954
  func.env.config.validateNoSetStateInRender ||
165703
165955
  func.env.config.enablePreserveExistingMemoizationGuarantees;
165956
+ const optionals = findOptionalPlaces(func);
165704
165957
  const sidemap = {
165705
165958
  functions: new Map(),
165706
165959
  manualMemos: new Map(),
165707
165960
  react: new Set(),
165708
165961
  maybeDeps: new Map(),
165709
165962
  maybeDepsLists: new Map(),
165963
+ optionals: optionals,
165710
165964
  };
165711
165965
  let nextManualMemoId = 0;
165712
165966
  const queuedInserts = new Map();
@@ -165792,6 +166046,47 @@ function dropManualMemoization(func) {
165792
166046
  }
165793
166047
  }
165794
166048
  }
166049
+ function findOptionalPlaces(fn) {
166050
+ const optionals = new Set();
166051
+ for (const [, block] of fn.body.blocks) {
166052
+ if (block.terminal.kind === 'optional' && block.terminal.optional) {
166053
+ const optionalTerminal = block.terminal;
166054
+ let testBlock = fn.body.blocks.get(block.terminal.test);
166055
+ loop: while (true) {
166056
+ const terminal = testBlock.terminal;
166057
+ switch (terminal.kind) {
166058
+ case 'branch': {
166059
+ if (terminal.fallthrough === optionalTerminal.fallthrough) {
166060
+ const consequent = fn.body.blocks.get(terminal.consequent);
166061
+ const last = consequent.instructions.at(-1);
166062
+ if (last !== undefined && last.value.kind === 'StoreLocal') {
166063
+ optionals.add(last.value.value.identifier.id);
166064
+ }
166065
+ break loop;
166066
+ } else {
166067
+ testBlock = fn.body.blocks.get(terminal.fallthrough);
166068
+ }
166069
+ break;
166070
+ }
166071
+ case 'optional':
166072
+ case 'logical':
166073
+ case 'sequence':
166074
+ case 'ternary': {
166075
+ testBlock = fn.body.blocks.get(terminal.fallthrough);
166076
+ break;
166077
+ }
166078
+ default: {
166079
+ CompilerError.invariant(false, {
166080
+ reason: `Unexpected terminal in optional`,
166081
+ loc: terminal.loc,
166082
+ });
166083
+ }
166084
+ }
166085
+ }
166086
+ }
166087
+ }
166088
+ return optionals;
166089
+ }
165795
166090
  function inferReactivePlaces(fn) {
165796
166091
  var _a;
165797
166092
  const reactiveIdentifiers = new ReactivityMap(findDisjointMutableValues(fn));
@@ -166549,7 +166844,7 @@ function alignReactiveScopesToBlockScopesHIR(fn) {
166549
166844
  recordPlace(terminal.id, operand, node);
166550
166845
  }
166551
166846
  const fallthrough = terminalFallthrough(terminal);
166552
- if (fallthrough !== null) {
166847
+ if (fallthrough !== null && terminal.kind !== 'branch') {
166553
166848
  const fallthroughBlock = fn.body.blocks.get(fallthrough);
166554
166849
  const nextId =
166555
166850
  (_e =
@@ -166937,13 +167232,13 @@ let Visitor$2 = class Visitor extends ReactiveFunctionVisitor {
166937
167232
  (_a = this.aliases.find(ident.identifier.id)) !== null && _a !== void 0
166938
167233
  ? _a
166939
167234
  : ident.identifier.id;
166940
- ident.path.forEach(key => {
167235
+ ident.path.forEach(token => {
166941
167236
  var _a;
166942
167237
  target &&
166943
167238
  (target =
166944
167239
  (_a = this.paths.get(target)) === null || _a === void 0
166945
167240
  ? void 0
166946
- : _a.get(key));
167241
+ : _a.get(token.property));
166947
167242
  });
166948
167243
  if (target && this.map.get(target) === 'Create') {
166949
167244
  scope.scope.dependencies.delete(ident);
@@ -168598,23 +168893,25 @@ function compareDeps(inferred, source) {
168598
168893
  }
168599
168894
  let isSubpath = true;
168600
168895
  for (let i = 0; i < Math.min(inferred.path.length, source.path.length); i++) {
168601
- if (inferred.path[i] !== source.path[i]) {
168896
+ if (inferred.path[i].property !== source.path[i].property) {
168602
168897
  isSubpath = false;
168603
168898
  break;
168899
+ } else if (inferred.path[i].optional !== source.path[i].optional) {
168900
+ return CompareDependencyResult.PathDifference;
168604
168901
  }
168605
168902
  }
168606
168903
  if (
168607
168904
  isSubpath &&
168608
168905
  (source.path.length === inferred.path.length ||
168609
168906
  (inferred.path.length >= source.path.length &&
168610
- !inferred.path.includes('current')))
168907
+ !inferred.path.some(token => token.property === 'current')))
168611
168908
  ) {
168612
168909
  return CompareDependencyResult.Ok;
168613
168910
  } else {
168614
168911
  if (isSubpath) {
168615
168912
  if (
168616
- source.path.includes('current') ||
168617
- inferred.path.includes('current')
168913
+ source.path.some(token => token.property === 'current') ||
168914
+ inferred.path.some(token => token.property === 'current')
168618
168915
  ) {
168619
168916
  return CompareDependencyResult.RefAccessDifference;
168620
168917
  } else {
@@ -168729,7 +169026,11 @@ class Visitor extends ReactiveFunctionVisitor {
168729
169026
  return null;
168730
169027
  }
168731
169028
  default: {
168732
- const dep = collectMaybeMemoDependencies(value, this.temporaries);
169029
+ const dep = collectMaybeMemoDependencies(
169030
+ value,
169031
+ this.temporaries,
169032
+ false
169033
+ );
168733
169034
  if (value.kind === 'StoreLocal' || value.kind === 'StoreContext') {
168734
169035
  const storeTarget = value.lvalue.place;
168735
169036
  (_a = state.manualMemoState) === null || _a === void 0
@@ -170036,9 +170337,10 @@ function findProgramSuppressions(programComments, ruleNames, flowSuppressions) {
170036
170337
  }
170037
170338
  function suppressionsToCompilerError(suppressionRanges) {
170038
170339
  var _a;
170039
- if (suppressionRanges.length === 0) {
170040
- return null;
170041
- }
170340
+ CompilerError.invariant(suppressionRanges.length !== 0, {
170341
+ reason: `Expected at least suppression comment source range`,
170342
+ loc: GeneratedSource,
170343
+ });
170042
170344
  const error = new CompilerError();
170043
170345
  for (const suppressionRange of suppressionRanges) {
170044
170346
  if (
@@ -170289,8 +170591,6 @@ function compileProgram(program, pass) {
170289
170591
  : DEFAULT_ESLINT_SUPPRESSIONS,
170290
170592
  pass.opts.flowSuppressions
170291
170593
  );
170292
- const lintError = suppressionsToCompilerError(suppressions);
170293
- let hasCriticalError = lintError != null;
170294
170594
  const queue = [];
170295
170595
  const compiledFns = [];
170296
170596
  const traverseFunction = (fn, pass) => {
@@ -170333,12 +170633,14 @@ function compileProgram(program, pass) {
170333
170633
  fn.node.body.directives
170334
170634
  );
170335
170635
  }
170336
- if (lintError != null) {
170636
+ let compiledFn;
170637
+ try {
170337
170638
  const suppressionsInFunction = filterSuppressionsThatAffectFunction(
170338
170639
  suppressions,
170339
170640
  fn
170340
170641
  );
170341
170642
  if (suppressionsInFunction.length > 0) {
170643
+ const lintError = suppressionsToCompilerError(suppressionsInFunction);
170342
170644
  if (optOutDirectives.length > 0) {
170343
170645
  logError(
170344
170646
  lintError,
@@ -170352,10 +170654,8 @@ function compileProgram(program, pass) {
170352
170654
  (_b = fn.node.loc) !== null && _b !== void 0 ? _b : null
170353
170655
  );
170354
170656
  }
170657
+ return null;
170355
170658
  }
170356
- }
170357
- let compiledFn;
170358
- try {
170359
170659
  compiledFn = compileFn(
170360
170660
  fn,
170361
170661
  environment,
@@ -170394,7 +170694,6 @@ function compileProgram(program, pass) {
170394
170694
  return null;
170395
170695
  }
170396
170696
  }
170397
- hasCriticalError || (hasCriticalError = isCriticalError(err));
170398
170697
  handleError(
170399
170698
  err,
170400
170699
  pass,
@@ -170421,7 +170720,7 @@ function compileProgram(program, pass) {
170421
170720
  }
170422
170721
  return null;
170423
170722
  }
170424
- if (!pass.opts.noEmit && !hasCriticalError) {
170723
+ if (!pass.opts.noEmit) {
170425
170724
  return compiledFn;
170426
170725
  }
170427
170726
  return null;