@neocompose/cli 0.84.1 → 0.84.3

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.
@@ -17587,7 +17587,7 @@ var init_registry = __esm({
17587
17587
  "../packages/manifest/schema-contract/registry.mjs"() {
17588
17588
  "use strict";
17589
17589
  PROJECT_SCHEMA_CONTRACT = Object.freeze({
17590
- cliVersion: "0.84.1",
17590
+ cliVersion: "0.84.3",
17591
17591
  projectFileUploadBatchSize: 32,
17592
17592
  documentRecords: {
17593
17593
  member: {
@@ -21418,7 +21418,8 @@ var init_executable_parser = __esm({
21418
21418
  }
21419
21419
  if (isIdentifier(t) && t.text === NEOSCRIPT_CONSTRUCTOR_KEYWORD) {
21420
21420
  this.next();
21421
- const className = isIdentifier(this.peek()) ? this.next().text : null;
21421
+ const classToken = isIdentifier(this.peek()) ? this.next() : null;
21422
+ const className = classToken?.text ?? null;
21422
21423
  const typeArguments = [];
21423
21424
  if (this.eat("operator", "<")) {
21424
21425
  if (className === null) {
@@ -21452,6 +21453,7 @@ var init_executable_parser = __esm({
21452
21453
  return {
21453
21454
  kind: "new",
21454
21455
  className,
21456
+ ...classToken ? { classNamePos: at(classToken) } : {},
21455
21457
  ...typeArguments.length > 0 ? { typeArguments } : {},
21456
21458
  args,
21457
21459
  ...hasArgumentList ? { hasArgumentList: true } : {},
@@ -26054,13 +26056,29 @@ function memberSavedForStorage(ctx, memberId, contextSaved, declarationClassId)
26054
26056
  if (isWritableConstraint(classStorage)) return true;
26055
26057
  if (classStorage === 1 /* Immutable */) return false;
26056
26058
  }
26057
- const effective = ctx.storageResolver.effectiveStorages(memberId);
26059
+ let effective = ctx.storageResolver.effectiveStorages(memberId);
26060
+ const visited = /* @__PURE__ */ new Set([memberId]);
26061
+ let currentId = memberId;
26062
+ let baseId = member?.extendsMemberId;
26063
+ while (effective.size === 0 && baseId !== void 0 && !visited.has(baseId)) {
26064
+ if (!isResolvedAbstract(ctx, currentId) && !isResolvedAbstract(ctx, baseId))
26065
+ break;
26066
+ visited.add(baseId);
26067
+ effective = ctx.storageResolver.effectiveStorages(baseId);
26068
+ currentId = baseId;
26069
+ baseId = ctx.exportData.members[baseId]?.extendsMemberId;
26070
+ }
26058
26071
  const hasWritable = effective.has(2 /* Save */) || effective.has(3 /* Session */);
26059
26072
  const hasStatic = effective.has(1 /* Immutable */);
26060
26073
  if (hasWritable && !hasStatic) return true;
26061
26074
  if (hasStatic && !hasWritable) return false;
26062
26075
  return contextSaved;
26063
26076
  }
26077
+ function isResolvedAbstract(ctx, memberId) {
26078
+ return isAbstractMember(
26079
+ resolveMemberById(ctx, memberId, `members.${memberId}`)
26080
+ );
26081
+ }
26064
26082
  function classAllowedStorage(ctx, classId) {
26065
26083
  return ctx.storageResolver.allowedStorage(classId);
26066
26084
  }
@@ -26950,7 +26968,7 @@ function typeInfoConstructedSuffix(ctx, typeInfo, saved, genericEnv, genericBind
26950
26968
  const argType = csharpTypeInfoValueType(
26951
26969
  ctx,
26952
26970
  argInfo,
26953
- saved,
26971
+ true,
26954
26972
  genericEnv,
26955
26973
  genericBindingSaved
26956
26974
  );
@@ -31635,6 +31653,22 @@ function neoScriptMemberLookupType(type) {
31635
31653
  }
31636
31654
  return nullable2 && current.nullable !== true ? { ...current, nullable: true } : current;
31637
31655
  }
31656
+ function neoScriptMemberReceiverType(type, memberName, project) {
31657
+ const primary = neoScriptMemberLookupType(type);
31658
+ if (primary.kind !== "named" || primary.narrowedInterfaces === void 0)
31659
+ return primary;
31660
+ const declaration = project.typeById.get(primary.typeId);
31661
+ if (declaration?.kind === "class" && (memberName === NEOSCRIPT_CLASS_ID_MEMBER || memberName === "Clone"))
31662
+ return primary;
31663
+ if (declaration?.members.some((member) => member.name === memberName))
31664
+ return primary;
31665
+ for (const bound of Object.values(primary.narrowedInterfaces)) {
31666
+ if (project.typeById.get(bound.typeId)?.members.some((member) => member.name === memberName)) {
31667
+ return { ...bound, nullable: primary.nullable === true };
31668
+ }
31669
+ }
31670
+ return primary;
31671
+ }
31638
31672
  function isNeoScriptHandleReferenceTarget(target, isValueType) {
31639
31673
  switch (target.kind) {
31640
31674
  case "list":
@@ -31952,6 +31986,20 @@ function isNeoScriptTypeAssignable(source, target, project) {
31952
31986
  if (isUnknownType(source) || isUnknownType(target)) return false;
31953
31987
  if (isNullType(source)) return isNullableType2(target);
31954
31988
  if (isNullableType2(source) && !isNullableType2(target)) return false;
31989
+ if (target.kind === "named" && target.narrowedInterfaces !== void 0) {
31990
+ for (const bound of Object.values(target.narrowedInterfaces)) {
31991
+ if (!isNeoScriptTypeAssignable(source, bound, project)) return false;
31992
+ }
31993
+ }
31994
+ if (source.kind === "named" && source.narrowedInterfaces !== void 0) {
31995
+ const direct = target.kind === "named" ? source.narrowedInterfaces[target.typeId] : void 0;
31996
+ if (direct !== void 0 && isNeoScriptTypeAssignable(direct, target, project))
31997
+ return true;
31998
+ for (const bound of Object.values(source.narrowedInterfaces)) {
31999
+ if (bound !== direct && isNeoScriptTypeAssignable(bound, target, project))
32000
+ return true;
32001
+ }
32002
+ }
31955
32003
  if (source.kind === "primitive" && target.kind === "primitive") {
31956
32004
  if (source.name === target.name) return true;
31957
32005
  return source.name === "int" && (target.name === "float" || target.name === "decimal");
@@ -32036,9 +32084,40 @@ function isNeoScriptTypeAssignable(source, target, project) {
32036
32084
  }
32037
32085
  return false;
32038
32086
  }
32087
+ function withoutNeoScriptInterfaceProofs(type) {
32088
+ if (type.kind !== "named" || type.narrowedInterfaces === void 0)
32089
+ return type;
32090
+ const { narrowedInterfaces: _proofs, ...declared } = type;
32091
+ return declared;
32092
+ }
32039
32093
  function commonNeoScriptAssignableType(left, right, project) {
32040
32094
  if (isNeoScriptTypeAssignable(left, right, project)) return right;
32041
32095
  if (isNeoScriptTypeAssignable(right, left, project)) return left;
32096
+ if (left.kind === "named" && right.kind === "named" && (left.narrowedInterfaces !== void 0 || right.narrowedInterfaces !== void 0)) {
32097
+ const declaredLeft = withoutNeoScriptInterfaceProofs(left);
32098
+ const declaredRight = withoutNeoScriptInterfaceProofs(right);
32099
+ const common = commonNeoScriptAssignableType(
32100
+ declaredLeft,
32101
+ declaredRight,
32102
+ project
32103
+ );
32104
+ if (common?.kind !== "named") return null;
32105
+ const proofs = {};
32106
+ for (const [source, other] of [
32107
+ [left, right],
32108
+ [right, left]
32109
+ ]) {
32110
+ for (const [id2, proof] of Object.entries(
32111
+ source.narrowedInterfaces ?? {}
32112
+ )) {
32113
+ if (proofs[id2] !== void 0) continue;
32114
+ const opposite = other.narrowedInterfaces?.[id2] ?? other;
32115
+ if (isNeoScriptTypeAssignable(opposite, proof, project))
32116
+ proofs[id2] = proof;
32117
+ }
32118
+ }
32119
+ return { ...common, narrowedInterfaces: proofs };
32120
+ }
32042
32121
  return null;
32043
32122
  }
32044
32123
  function isNeoVariantTypeId(typeId, project) {
@@ -34302,17 +34381,22 @@ function mergeFactSets(sets) {
34302
34381
  )
34303
34382
  );
34304
34383
  }
34305
- function mergeNarrowingMaps(maps) {
34384
+ function mergeNarrowingMaps(maps, project) {
34306
34385
  const first = maps[0];
34307
34386
  if (!first) return /* @__PURE__ */ new Map();
34308
34387
  const result = /* @__PURE__ */ new Map();
34309
34388
  for (const [path, narrowed] of first) {
34310
- if (maps.slice(1).every((map) => {
34311
- const candidate = map.get(path);
34312
- return candidate?.rootEntry === narrowed.rootEntry && typeRefsEqual(candidate.type, narrowed.type);
34313
- })) {
34314
- result.set(path, narrowed);
34389
+ let common = narrowed.type;
34390
+ for (let index = 1; index < maps.length; index++) {
34391
+ const candidate = maps[index].get(path);
34392
+ if (candidate?.rootEntry !== narrowed.rootEntry) {
34393
+ common = null;
34394
+ break;
34395
+ }
34396
+ common = commonNeoScriptAssignableType(common, candidate.type, project);
34397
+ if (common === null) break;
34315
34398
  }
34399
+ if (common !== null) result.set(path, { ...narrowed, type: common });
34316
34400
  }
34317
34401
  return result;
34318
34402
  }
@@ -34341,6 +34425,16 @@ function typeRefsEqual(left, right) {
34341
34425
  if (left.kind === "named" && right.kind === "named") {
34342
34426
  const leftArgs = left.typeArguments ?? [];
34343
34427
  const rightArgs = right.typeArguments ?? [];
34428
+ if (left.narrowedInterfaces !== right.narrowedInterfaces) {
34429
+ const leftBounds = Object.entries(left.narrowedInterfaces ?? {});
34430
+ const rightBounds = right.narrowedInterfaces ?? {};
34431
+ if (leftBounds.length !== Object.keys(rightBounds).length) return false;
34432
+ for (const [id2, leftBound] of leftBounds) {
34433
+ const rightBound = rightBounds[id2];
34434
+ if (rightBound === void 0 || !typeRefsEqual(leftBound, rightBound))
34435
+ return false;
34436
+ }
34437
+ }
34344
34438
  return left.typeId === right.typeId && leftArgs.length === rightArgs.length && leftArgs.every((item, index) => {
34345
34439
  const other = rightArgs[index];
34346
34440
  return other !== void 0 && typeRefsEqual(item, other);
@@ -35320,6 +35414,10 @@ function typesOverlap(left, right, project) {
35320
35414
  if (isUnknown(left) || isUnknown(right)) return true;
35321
35415
  if (isNull(left)) return isNullable(right);
35322
35416
  if (isNull(right)) return isNullable(left);
35417
+ left = neoScriptMemberLookupType(left);
35418
+ right = neoScriptMemberLookupType(right);
35419
+ if (left.kind === "typeParameter" || right.kind === "typeParameter")
35420
+ return true;
35323
35421
  if (isNeoScriptTypeAssignable(left, right, project) || isNeoScriptTypeAssignable(right, left, project))
35324
35422
  return true;
35325
35423
  if (left.kind === "named" && right.kind === "named") {
@@ -36689,7 +36787,7 @@ var init_strict_resolver = __esm({
36689
36787
  statement.init.pos
36690
36788
  );
36691
36789
  }
36692
- const localType = declared ?? initial.type;
36790
+ const localType = declared ?? withoutNeoScriptInterfaceProofs(initial.type);
36693
36791
  if (declared) {
36694
36792
  this.requireAssignable(
36695
36793
  initial.type,
@@ -36704,16 +36802,18 @@ var init_strict_resolver = __esm({
36704
36802
  initial.pointer,
36705
36803
  this.project
36706
36804
  );
36707
- scope.define(
36708
- scopeVariable(
36709
- statement.name,
36710
- local,
36711
- localType,
36712
- "local" /* Local */,
36713
- localOwnership(initial),
36714
- this.localWriteTargetRoot(initial, scope)
36715
- )
36805
+ const entry = scopeVariable(
36806
+ statement.name,
36807
+ local,
36808
+ localType,
36809
+ "local" /* Local */,
36810
+ localOwnership(initial),
36811
+ this.localWriteTargetRoot(initial, scope)
36716
36812
  );
36813
+ scope.define(entry);
36814
+ if (inferred && localType !== initial.type) {
36815
+ scope.narrow(statement.name, entry, initial.type);
36816
+ }
36717
36817
  return { type: "variable" /* Variable */, variable: local };
36718
36818
  }
36719
36819
  case "if": {
@@ -36768,7 +36868,8 @@ var init_strict_resolver = __esm({
36768
36868
  mergeBranchInvalidations(scope, branchExitOwnershipScopes);
36769
36869
  if (branchExitNarrowings.length > 0) {
36770
36870
  for (const [path, narrowed] of mergeNarrowingMaps(
36771
- branchExitNarrowings
36871
+ branchExitNarrowings,
36872
+ this.project
36772
36873
  )) {
36773
36874
  const rootEntry = scope.lookup(pathRoot(path));
36774
36875
  if (rootEntry === narrowed.rootEntry) {
@@ -37694,7 +37795,7 @@ var init_strict_resolver = __esm({
37694
37795
  }
37695
37796
  mergeLoopNarrowings(parent, exitPaths) {
37696
37797
  if (exitPaths.length === 0) return;
37697
- const merged = mergeNarrowingMaps(exitPaths);
37798
+ const merged = mergeNarrowingMaps(exitPaths, this.project);
37698
37799
  for (const [path, narrowed] of parent.effectiveNarrowedPaths()) {
37699
37800
  const common = merged.get(path);
37700
37801
  if (parent.containsEntry(narrowed.rootEntry) && (common?.rootEntry !== narrowed.rootEntry || !typeRefsEqual(common.type, narrowed.type))) {
@@ -39447,8 +39548,13 @@ var init_strict_resolver = __esm({
39447
39548
  expression.receiver,
39448
39549
  scope
39449
39550
  );
39450
- if (receiverExpression.type.kind !== "named") return null;
39451
- owner = this.project.typeById.get(receiverExpression.type.typeId);
39551
+ const memberType2 = neoScriptMemberReceiverType(
39552
+ receiverExpression.type,
39553
+ expression.name,
39554
+ this.project
39555
+ );
39556
+ if (memberType2.kind !== "named") return null;
39557
+ owner = this.project.typeById.get(memberType2.typeId);
39452
39558
  symbol = owner?.members.find(
39453
39559
  (candidate) => candidate.name === expression.name && (candidate.kind === "function" || candidate.kind === "method")
39454
39560
  );
@@ -39459,7 +39565,10 @@ var init_strict_resolver = __esm({
39459
39565
  expression.pos
39460
39566
  );
39461
39567
  }
39462
- receiver = { kind: "instance", expression: receiverExpression };
39568
+ receiver = {
39569
+ kind: "instance",
39570
+ expression: { ...receiverExpression, type: memberType2 }
39571
+ };
39463
39572
  }
39464
39573
  } else {
39465
39574
  return null;
@@ -39536,9 +39645,13 @@ var init_strict_resolver = __esm({
39536
39645
  if (symbol === void 0 || symbol.static !== true) return null;
39537
39646
  } else {
39538
39647
  const receiver2 = this.resolveExpression(expression.receiver, scope);
39539
- if (receiver2.type.kind !== "named") return null;
39540
- receiverType = receiver2.type;
39541
- owner = this.project.typeById.get(receiver2.type.typeId);
39648
+ receiverType = neoScriptMemberReceiverType(
39649
+ receiver2.type,
39650
+ expression.name,
39651
+ this.project
39652
+ );
39653
+ if (receiverType.kind !== "named") return null;
39654
+ owner = this.project.typeById.get(receiverType.typeId);
39542
39655
  symbol = owner?.members.find(
39543
39656
  (candidate) => candidate.name === expression.name && (candidate.kind === "function" || candidate.kind === "method")
39544
39657
  );
@@ -39616,6 +39729,7 @@ var init_strict_resolver = __esm({
39616
39729
  pos
39617
39730
  );
39618
39731
  }
39732
+ entryType = withoutNeoScriptInterfaceProofs(entryType);
39619
39733
  for (const item of resolved) {
39620
39734
  const common = commonNeoScriptAssignableType(
39621
39735
  entryType,
@@ -39640,7 +39754,7 @@ var init_strict_resolver = __esm({
39640
39754
  }
39641
39755
  const type = {
39642
39756
  kind: "list",
39643
- elementType: entryType
39757
+ elementType: withoutNeoScriptInterfaceProofs(entryType)
39644
39758
  };
39645
39759
  const wire = toWireType(type, this.project);
39646
39760
  if (wire.type !== 6 /* List */) {
@@ -39706,6 +39820,7 @@ var init_strict_resolver = __esm({
39706
39820
  if (!keyType || !valueType) {
39707
39821
  throw new CompileError("Dictionary literal type inference failed.", pos);
39708
39822
  }
39823
+ valueType = withoutNeoScriptInterfaceProofs(valueType);
39709
39824
  for (const entry of resolved) {
39710
39825
  if (expectedDictionary) {
39711
39826
  this.requireAssignable(
@@ -39732,7 +39847,7 @@ var init_strict_resolver = __esm({
39732
39847
  const type = {
39733
39848
  kind: "dictionary",
39734
39849
  keyType,
39735
- valueType
39850
+ valueType: withoutNeoScriptInterfaceProofs(valueType)
39736
39851
  };
39737
39852
  const wire = toWireType(type, this.project);
39738
39853
  if (wire.type !== 5 /* Dictionary */) {
@@ -39988,8 +40103,19 @@ var init_strict_resolver = __esm({
39988
40103
  const target = this.resolveType(fact.targetType);
39989
40104
  const targetDefinition = target.kind === "named" ? this.project.typeById.get(target.typeId) : void 0;
39990
40105
  const naturalDefinition = natural.type.kind === "named" ? this.project.typeById.get(natural.type.typeId) : void 0;
39991
- const retainConcreteClass = !fact.bindingName && naturalDefinition?.kind === "class" && targetDefinition?.kind === "interface";
39992
- const narrowed = retainConcreteClass ? { ...natural.type, nullable: false } : { ...target, nullable: false };
40106
+ let narrowed = { ...target, nullable: false };
40107
+ if (!fact.bindingName && natural.type.kind === "named" && (naturalDefinition?.kind === "class" || naturalDefinition?.kind === "interface") && target.kind === "named" && targetDefinition?.kind === "interface") {
40108
+ narrowed = { ...natural.type, nullable: false };
40109
+ if (!isNeoScriptTypeAssignable(narrowed, target, this.project)) {
40110
+ narrowed = {
40111
+ ...narrowed,
40112
+ narrowedInterfaces: {
40113
+ ...natural.type.narrowedInterfaces,
40114
+ [target.typeId]: target
40115
+ }
40116
+ };
40117
+ }
40118
+ }
39993
40119
  if (mode === "all" && fact.path !== null && rootEntry !== null && place.type.kind !== "reference") {
39994
40120
  targetScope.narrow(fact.path, rootEntry, narrowed);
39995
40121
  }
@@ -40582,7 +40708,11 @@ var init_strict_resolver = __esm({
40582
40708
  if (receiver.dialogues !== void 0) {
40583
40709
  return this.resolveDialogueGroupRead(receiver, name, pos);
40584
40710
  }
40585
- const memberReceiverType = neoScriptMemberLookupType(receiver.type);
40711
+ const memberReceiverType = neoScriptMemberReceiverType(
40712
+ receiver.type,
40713
+ name,
40714
+ this.project
40715
+ );
40586
40716
  if (memberReceiverType.kind === "named") {
40587
40717
  const type = this.project.typeById.get(memberReceiverType.typeId);
40588
40718
  if (!type) {
@@ -41394,7 +41524,7 @@ var init_strict_resolver = __esm({
41394
41524
  }
41395
41525
  const type = {
41396
41526
  kind: "list",
41397
- elementType: entryType
41527
+ elementType: withoutNeoScriptInterfaceProofs(entryType)
41398
41528
  };
41399
41529
  const wire = toWireType(type, this.project);
41400
41530
  if (wire.type !== 6 /* List */) {
@@ -41635,7 +41765,11 @@ var init_strict_resolver = __esm({
41635
41765
  pos
41636
41766
  );
41637
41767
  }
41638
- const memberReceiverType = neoScriptMemberLookupType(receiver.type);
41768
+ const memberReceiverType = neoScriptMemberReceiverType(
41769
+ receiver.type,
41770
+ callee.name,
41771
+ this.project
41772
+ );
41639
41773
  const namedType2 = memberReceiverType.kind === "named" ? this.project.typeById.get(memberReceiverType.typeId) : void 0;
41640
41774
  const member = namedType2?.members.find(
41641
41775
  (candidate) => (candidate.kind === "function" || candidate.kind === "method") && candidate.name === callee.name
@@ -44060,7 +44194,11 @@ var init_strict_resolver = __esm({
44060
44194
  }
44061
44195
  const receiver = receiverValue();
44062
44196
  if (receiver.dialogues !== void 0) return null;
44063
- const memberReceiverType = neoScriptMemberLookupType(receiver.type);
44197
+ const memberReceiverType = neoScriptMemberReceiverType(
44198
+ receiver.type,
44199
+ memberName,
44200
+ this.project
44201
+ );
44064
44202
  if (memberReceiverType.kind !== "named") return null;
44065
44203
  const type = this.project.typeById.get(memberReceiverType.typeId);
44066
44204
  const symbol = type?.members.find(
@@ -50978,7 +51116,29 @@ function validateExpression(expression, expected, scope, environment, uri, range
50978
51116
  );
50979
51117
  return;
50980
51118
  }
50981
- if (!declaration) return;
51119
+ if (!declaration) {
51120
+ if (expression.className !== null && !environment.projectIndex.typeByName.has(expression.className) && semanticTypeRef(
51121
+ {
51122
+ name: expression.className,
51123
+ ...expression.typeArguments ? { arguments: expression.typeArguments.map(semanticAstType) } : {}
51124
+ },
51125
+ scope,
51126
+ environment
51127
+ ) === void 0) {
51128
+ pushDiagnostic(
51129
+ diagnostics,
51130
+ uri,
51131
+ anchor ? anchorSpan(
51132
+ anchor,
51133
+ expression.classNamePos ?? expression.pos,
51134
+ expression.className.length
51135
+ ) : range2,
51136
+ "unknown-construction-type",
51137
+ `Unknown class '${expression.className}'.`
51138
+ );
51139
+ }
51140
+ return;
51141
+ }
50982
51142
  if (declaration.modifiers.includes("abstract")) {
50983
51143
  pushDiagnostic(
50984
51144
  diagnostics,
@@ -55341,7 +55501,7 @@ function sourceParameter(parameter4, owner, typeIds, id2, functionTypeParameters
55341
55501
  };
55342
55502
  }
55343
55503
  function substituteInheritedSourceMember(member, baseInfo, resolvedBaseType) {
55344
- if (baseInfo.declaration.kind !== "class" || resolvedBaseType.kind !== "named") {
55504
+ if (baseInfo.declaration.kind !== "class" && baseInfo.declaration.kind !== "interface" || resolvedBaseType.kind !== "named") {
55345
55505
  return {
55346
55506
  ...member,
55347
55507
  inheritedFrom: member.inheritedFrom ?? {
@@ -82579,6 +82739,7 @@ function createdSessionValuesSince(ctx, checkpoint) {
82579
82739
  return created;
82580
82740
  }
82581
82741
  function exportInitializerCollections(created, writes, ctx) {
82742
+ const inPlace = (value) => value instanceof RuntimeSet ? exportRuntimeSetValue(value, ctx) : value;
82582
82743
  const assignedValues = /* @__PURE__ */ new Set();
82583
82744
  const mutatedIds = /* @__PURE__ */ new Set();
82584
82745
  for (const write of writes) {
@@ -82586,83 +82747,134 @@ function exportInitializerCollections(created, writes, ctx) {
82586
82747
  if (destination !== void 0 && "containerValueId" in destination)
82587
82748
  mutatedIds.add(destination.containerValueId);
82588
82749
  if (write.kind === "assign" && write.valueId === void 0 && typeof write.value === "object" && write.value !== null) {
82589
- assignedValues.add(write.value);
82750
+ assignedValues.add(inPlace(write.value));
82590
82751
  }
82591
82752
  }
82592
82753
  const candidates = /* @__PURE__ */ new Set();
82754
+ const inlineFieldsByRowId = /* @__PURE__ */ new Map();
82593
82755
  for (const row of created) {
82594
- if (assignedValues.has(row.value) || row.classId === void 0 && mutatedIds.has(row.id) || Array.isArray(row.value) && row.value.length > 0 && ctx.__unorderedListProjections?.byContainerId.has(row.id)) {
82756
+ const inlineFields = inlineCollectionFields(row, ctx);
82757
+ if (inlineFields !== null) inlineFieldsByRowId.set(row.id, inlineFields);
82758
+ if (inlineFields !== null || assignedValues.has(inPlace(row.value)) || row.classId === void 0 && mutatedIds.has(row.id) || Array.isArray(row.value) && row.value.length > 0 && ctx.__unorderedListProjections?.byContainerId.has(row.id)) {
82595
82759
  candidates.add(row.id);
82596
82760
  }
82597
82761
  }
82598
82762
  if (candidates.size === 0) return created;
82599
82763
  invalidateEvaluatorIndexes(ctx, null);
82600
82764
  const extra = [];
82601
- const exported = created.map((row) => {
82602
- if (!candidates.has(row.id)) return row;
82603
- const member = memberForValueRow(row, ctx);
82604
- if (member === null) return row;
82605
- if (!isMemberWithEntries(member)) return row;
82606
- if (isMemberEntryCollectionBase(member) && listKindOf(member) === 1 /* Unordered */) {
82607
- return { ...row, value: [] };
82608
- }
82609
- if (!assignedValues.has(row.value) && !mutatedIds.has(row.id)) return row;
82610
- const values = [];
82765
+ const encode = (member, value, genericEnv, collectionOwnerId) => {
82766
+ const rows = [];
82611
82767
  const declarations = /* @__PURE__ */ new Map();
82612
- const genericEnv = runtimeGenericEnvForValueRow(row, ctx, /* @__PURE__ */ new Set());
82613
- overlayConcreteGenericEntries(
82614
- genericEnv,
82615
- envFromStamp(row.genericBindings)
82616
- );
82617
- const materialized = materializeConstructorArgumentValue({
82768
+ const root = materializeConstructorArgumentValue({
82618
82769
  member,
82619
- value: row.value,
82770
+ value,
82620
82771
  genericEnv,
82621
82772
  ctx,
82622
- createdValues: values,
82773
+ createdValues: rows,
82623
82774
  createdById: /* @__PURE__ */ new Map(),
82624
82775
  storageKeyDeclarations: declarations,
82625
- collectionEntriesAreReferences: assignedValues.has(row.value) ? false : void 0,
82626
- collectionOwnerId: row.id
82627
- });
82628
- const encoded = { ...row, value: materialized.value };
82629
- const children = values.filter((value) => value !== materialized);
82630
- declarations.delete(materialized.id);
82631
- const groupId = constructorGroupForRow(row.id, ctx);
82632
- retargetConstructorGroupDependencies(
82633
- materialized.id,
82634
- groupId ?? row.id,
82635
- ctx
82636
- );
82776
+ collectionEntriesAreReferences: assignedValues.has(value) ? false : void 0,
82777
+ collectionOwnerId
82778
+ });
82779
+ const children = rows.filter((row) => row !== root);
82780
+ return { root, children, declarations };
82781
+ };
82782
+ const adopt = (owner, rootId, rows, declarations) => {
82783
+ const groupId = constructorGroupForRow(owner.id, ctx);
82784
+ retargetConstructorGroupDependencies(rootId, groupId ?? owner.id, ctx);
82637
82785
  if (groupId !== null) {
82638
82786
  const state = ctx.__executionState;
82639
82787
  const group = state?.constructorGroups.get(groupId);
82640
- for (const child2 of children) {
82641
- retargetConstructorGroupDependencies(child2.id, groupId, ctx);
82642
- group?.add(child2.id);
82643
- state?.constructorGroupByRowId.set(child2.id, groupId);
82788
+ for (const row of rows) {
82789
+ retargetConstructorGroupDependencies(row.id, groupId, ctx);
82790
+ group?.add(row.id);
82791
+ state?.constructorGroupByRowId.set(row.id, groupId);
82644
82792
  }
82645
82793
  }
82646
- stampCreatedValuesMapKey(children, row.mapKey);
82794
+ stampCreatedValuesMapKey(rows, owner.mapKey);
82647
82795
  applyDeclaredStorageKeyOverrides({
82648
- createdValues: [encoded, ...children],
82796
+ createdValues: [owner, ...rows],
82649
82797
  declarationByValueId: declarations
82650
82798
  });
82651
- for (const child2 of children) {
82652
- if (!isLiteralValueContent(child2)) {
82799
+ for (const row of rows) {
82800
+ if (!isLiteralValueContent(row)) {
82653
82801
  throw new NSGetterRuntimeError(
82654
82802
  "Initializer collection produced an unevaluated row."
82655
82803
  );
82656
82804
  }
82657
- extra.push(child2);
82805
+ extra.push(row);
82658
82806
  }
82659
82807
  for (const [id2, declaration] of declarations) {
82660
82808
  ctx.__createdStorageKeyDeclarations?.set(id2, declaration);
82661
82809
  }
82810
+ };
82811
+ const exported = created.map((row) => {
82812
+ if (!candidates.has(row.id)) return row;
82813
+ const inlineFields = inlineFieldsByRowId.get(row.id);
82814
+ if (inlineFields !== void 0) {
82815
+ const record7 = { ...inlineFields.record };
82816
+ const encoded2 = { ...row, value: record7 };
82817
+ for (const [key, member2] of inlineFields.members) {
82818
+ const { root: root2, children: children2, declarations: declarations2 } = encode(
82819
+ member2,
82820
+ inPlace(record7[key]),
82821
+ inlineFields.genericEnv
82822
+ );
82823
+ record7[key] = root2.id;
82824
+ adopt(encoded2, root2.id, [root2, ...children2], declarations2);
82825
+ }
82826
+ return encoded2;
82827
+ }
82828
+ const member = memberForValueRow(row, ctx);
82829
+ if (member === null) return row;
82830
+ if (!isMemberWithEntries(member)) return row;
82831
+ if (isMemberEntryCollectionBase(member) && listKindOf(member) === 1 /* Unordered */) {
82832
+ return { ...row, value: [] };
82833
+ }
82834
+ const value = inPlace(row.value);
82835
+ if (!assignedValues.has(value) && !mutatedIds.has(row.id)) return row;
82836
+ const { root, children, declarations } = encode(
82837
+ member,
82838
+ value,
82839
+ rowGenericEnv(row, ctx),
82840
+ row.id
82841
+ );
82842
+ const encoded = { ...row, value: root.value };
82843
+ declarations.delete(root.id);
82844
+ adopt(encoded, root.id, children, declarations);
82662
82845
  return encoded;
82663
82846
  });
82664
82847
  return [...exported, ...extra];
82665
82848
  }
82849
+ function inlineCollectionFields(row, ctx) {
82850
+ if (typeof row.classId !== "string") return null;
82851
+ if (!isPlainRecord2(row.value)) return null;
82852
+ let fields = null;
82853
+ for (const key in row.value) {
82854
+ const value = row.value[key];
82855
+ if (typeof value !== "object" || value === null) continue;
82856
+ const rawMember = memberForCustomSchemaValue(row.classId, key, ctx);
82857
+ if (rawMember === null) continue;
82858
+ fields ??= {
82859
+ record: row.value,
82860
+ members: /* @__PURE__ */ new Map(),
82861
+ genericEnv: rowGenericEnv(row, ctx)
82862
+ };
82863
+ const member = substituteMember(
82864
+ rawMember,
82865
+ fields.genericEnv,
82866
+ ctx.vm.members,
82867
+ cachedResolvedMember(rawMember, ctx)
82868
+ );
82869
+ if (isMemberWithEntries(member)) fields.members.set(key, member);
82870
+ }
82871
+ return fields === null || fields.members.size === 0 ? null : fields;
82872
+ }
82873
+ function rowGenericEnv(row, ctx) {
82874
+ const genericEnv = runtimeGenericEnvForValueRow(row, ctx, /* @__PURE__ */ new Set());
82875
+ overlayConcreteGenericEntries(genericEnv, envFromStamp(row.genericBindings));
82876
+ return genericEnv;
82877
+ }
82666
82878
  function prepareSessionValueExport(ctx, checkpoint, writes) {
82667
82879
  const created = createdSessionValuesSince(ctx, checkpoint);
82668
82880
  if (created.length === 0) return;
@@ -94015,6 +94227,7 @@ function clonedConstructorProvenance(source) {
94015
94227
  }
94016
94228
  function cloneConstructorLiteralValue(value) {
94017
94229
  if (typeof value !== "object" || value === null) return value;
94230
+ if (value instanceof NSSlotReference) return value.targetId;
94018
94231
  if (Array.isArray(value)) {
94019
94232
  return value.map((entry) => cloneConstructorLiteralValue(entry));
94020
94233
  }
@@ -96060,7 +96273,7 @@ var init_constructor_argument_ownership = __esm({
96060
96273
  const typeInfo = parameterTypes.get(parameterId);
96061
96274
  return [
96062
96275
  parameterId,
96063
- typeInfo !== void 0 && isAggregateTypeInfo(typeInfo) && typeof argument2 === "string" ? rewriteId(argument2) : argument2
96276
+ typeInfo !== void 0 && (isAggregateTypeInfo(typeInfo) || typeInfo.type === 29 /* Reference */) && typeof argument2 === "string" ? rewriteId(argument2) : argument2
96064
96277
  ];
96065
96278
  }
96066
96279
  )
@@ -96096,6 +96309,41 @@ var init_constructor_argument_ownership = __esm({
96096
96309
  ids.push(edge.targetValueId);
96097
96310
  return ids;
96098
96311
  }
96312
+ /** The targets a row's Reference creation data names (P112 §1.1). */
96313
+ referenceArgumentIds(row) {
96314
+ if (!isLiteralValueContent(row)) return [];
96315
+ const args = row.constructorArgs;
96316
+ if (args === void 0 || args === null) return [];
96317
+ const ids = [];
96318
+ for (const parameterId of this.referenceParameterIds(row)) {
96319
+ const argument2 = args[parameterId];
96320
+ if (typeof argument2 === "string") ids.push(argument2);
96321
+ }
96322
+ return ids;
96323
+ }
96324
+ /** Creation data with each Reference argument's target remapped (P112 §1.1). */
96325
+ remapReferenceArguments(row, remap, contextualMember) {
96326
+ const args = row.constructorArgs;
96327
+ if (args === void 0 || args === null) return args;
96328
+ let remapped;
96329
+ for (const parameterId of this.referenceParameterIds(
96330
+ row,
96331
+ contextualMember
96332
+ )) {
96333
+ const argument2 = args[parameterId];
96334
+ if (typeof argument2 !== "string") continue;
96335
+ const target = remap(argument2);
96336
+ if (target !== argument2) (remapped ??= { ...args })[parameterId] = target;
96337
+ }
96338
+ return remapped ?? args;
96339
+ }
96340
+ *referenceParameterIds(row, contextualMember) {
96341
+ for (const [parameterId, typeInfo] of this.constructorParameterTypes(
96342
+ row,
96343
+ contextualMember
96344
+ ))
96345
+ if (typeInfo.type === 29 /* Reference */) yield parameterId;
96346
+ }
96099
96347
  slotEntries(row) {
96100
96348
  const value = row.value;
96101
96349
  switch (this.referenceSlots(row.id, void 0, value)) {
@@ -98003,7 +98251,11 @@ function resolveVirtualInstanceGraph(args) {
98003
98251
  }
98004
98252
  }
98005
98253
  }
98006
- const virtualRow = rewriteExpandedRow(indexed, expansion);
98254
+ const virtualRow = rewriteExpandedRow(
98255
+ indexed,
98256
+ expansion,
98257
+ materializedGraph
98258
+ );
98007
98259
  const location3 = {
98008
98260
  id: effectiveId2,
98009
98261
  instanceRootId: args.instanceRoot.id,
@@ -99457,6 +99709,16 @@ function sparsifyConstructedInstance(args) {
99457
99709
  protectedValueIds.add(location3.materializedRow.id);
99458
99710
  }
99459
99711
  }
99712
+ const rootId = args.constructed.root.id;
99713
+ const locationValueId = (location3) => args.virtualValueIdForSource?.(rootId, location3.sourceIdentity) ?? location3.virtualRow.id;
99714
+ if (args.bindingTargets !== void 0)
99715
+ pinReferencedSlots(
99716
+ graph,
99717
+ rootId,
99718
+ args.bindingTargets,
99719
+ locationValueId,
99720
+ protectedValueIds
99721
+ );
99460
99722
  let plan;
99461
99723
  try {
99462
99724
  plan = planCollapseVirtualInstance({
@@ -99488,10 +99750,7 @@ function sparsifyConstructedInstance(args) {
99488
99750
  if (real === null || deletedIds.has(real.id)) continue;
99489
99751
  nextIdById.set(
99490
99752
  real.id,
99491
- location3.parentSegment === null ? args.constructed.root.id : args.virtualValueIdForSource?.(
99492
- args.constructed.root.id,
99493
- location3.sourceIdentity
99494
- ) ?? location3.virtualRow.id
99753
+ location3.parentSegment === null ? rootId : locationValueId(location3)
99495
99754
  );
99496
99755
  }
99497
99756
  nextIdById.set(args.constructed.root.id, args.constructed.root.id);
@@ -99590,6 +99849,8 @@ function restoreRowsRetainedRowsName(materializedGraph, rows, updatedValueById,
99590
99849
  updated === void 0 ? row : { ...row, value: updated }
99591
99850
  ))
99592
99851
  restore(valueId);
99852
+ for (const valueId of materializedGraph.referenceArgumentIds(row))
99853
+ restore(valueId);
99593
99854
  entriesByContainerId ??= buildUnorderedListMembershipIndex(rows);
99594
99855
  for (const valueId of entriesByContainerId.get(row.id) ?? [])
99595
99856
  restore(valueId);
@@ -99712,6 +99973,24 @@ function childEnvForRow(member, row, genericEnv, document) {
99712
99973
  }
99713
99974
  return instanceEnv;
99714
99975
  }
99976
+ function pinReferencedSlots(graph, rootId, targets, locationValueId, pinned) {
99977
+ if (targets.ids.size === 0) return;
99978
+ const matched = /* @__PURE__ */ new Set();
99979
+ for (const location3 of graph.locationsByPath.values()) {
99980
+ if (location3.parentSegment === null) continue;
99981
+ const valueId = locationValueId(location3);
99982
+ if (!targets.ids.has(valueId)) continue;
99983
+ matched.add(valueId);
99984
+ if (location3.materializedRow !== null)
99985
+ pinned.add(location3.materializedRow.id);
99986
+ }
99987
+ for (const valueId of targets.pendingIdsByRootId.get(rootId) ?? []) {
99988
+ if (matched.has(valueId)) continue;
99989
+ throw new Error(
99990
+ `A binding names ${valueId}, which construction ${rootId} does not build.`
99991
+ );
99992
+ }
99993
+ }
99715
99994
  function indexExpansion(args) {
99716
99995
  const rowsByExpandedId = args.indexedRows?.rowsById ?? new Map([
99717
99996
  ...args.expandedRows.map((row) => [row.id, row]),
@@ -99978,7 +100257,7 @@ function planAtomicCollectionOverrideWrite(args) {
99978
100257
  childId = parent.id;
99979
100258
  }
99980
100259
  }
99981
- function rewriteExpandedRow(node, expansion) {
100260
+ function rewriteExpandedRow(node, expansion, graph) {
99982
100261
  const rewrite = (id2) => expansion.nodesByExpandedId.get(id2)?.virtualId ?? id2;
99983
100262
  const row = cloneRow(node.expandedRow);
99984
100263
  row.id = node.virtualId;
@@ -100000,6 +100279,12 @@ function rewriteExpandedRow(node, expansion) {
100000
100279
  if (node.member.kind === 9 /* Lookup */) {
100001
100280
  row.value = remapLookupSelection(row.value, rewrite);
100002
100281
  }
100282
+ if (isLiteralValueContent(row) && row.constructorArgs !== void 0)
100283
+ row.constructorArgs = graph.remapReferenceArguments(
100284
+ row,
100285
+ rewrite,
100286
+ node.member
100287
+ );
100003
100288
  if (typeof row.containerId === "string") {
100004
100289
  row.containerId = rewrite(row.containerId);
100005
100290
  }
@@ -100216,6 +100501,18 @@ function memberIdOf(member) {
100216
100501
  function appendVirtualValuePath(parent, segment) {
100217
100502
  return `${parent}/${JSON.stringify(segment)}`;
100218
100503
  }
100504
+ function constructedSlotValueId(rootId, steps) {
100505
+ let pathKey = ROOT_PATH;
100506
+ for (const step of steps)
100507
+ pathKey = appendVirtualValuePath(pathKey, {
100508
+ kind: "class",
100509
+ schemaKey: step.schemaKey
100510
+ });
100511
+ const memberId = steps.at(-1)?.memberId;
100512
+ if (memberId === void 0)
100513
+ throw new Error(`Construction ${rootId} names no slot.`);
100514
+ return derivedVirtualValueId(rootId, `path:${memberId}:${pathKey}`);
100515
+ }
100219
100516
  function parentPathKey(pathKey) {
100220
100517
  if (pathKey === ROOT_PATH) return null;
100221
100518
  const separator = lastPathSeparator(pathKey);
@@ -123765,6 +124062,7 @@ var init_collection_binding_materialization = __esm({
123765
124062
  "../src/database/collection-binding-materialization.ts"() {
123766
124063
  "use strict";
123767
124064
  init_members();
124065
+ init_constructor_argument_ownership();
123768
124066
  init_virtual_instance_values();
123769
124067
  init_headless_virtual_instance_lookups();
123770
124068
  init_document_initializer_compiler();
@@ -123781,6 +124079,7 @@ var init_collection_binding_materialization = __esm({
123781
124079
  pathRowsByRootId = /* @__PURE__ */ new Map();
123782
124080
  stored;
123783
124081
  lookups;
124082
+ schema;
123784
124083
  resolvePath(rootId, segments) {
123785
124084
  let id2 = rootId;
123786
124085
  const pathRows = this.pathRowsByRootId.get(rootId) ?? /* @__PURE__ */ new Set();
@@ -123838,17 +124137,20 @@ var init_collection_binding_materialization = __esm({
123838
124137
  valueId: id2,
123839
124138
  value: row.value
123840
124139
  });
124140
+ const created = [];
123841
124141
  for (const create of plan.creates) {
123842
124142
  pathRows?.add(create.id);
123843
124143
  const { valuePlacement: _placement, ...fields } = create;
123844
124144
  const previous = this.rows.get(create.id);
123845
- this.rows.set(create.id, {
124145
+ const row2 = {
123846
124146
  ...fields,
123847
124147
  value: mergeBodies(fields.value, previous?.value),
123848
124148
  projectId: this.document.project.id,
123849
124149
  createdAt: 0,
123850
124150
  updatedAt: 0
123851
- });
124151
+ };
124152
+ this.rows.set(create.id, row2);
124153
+ created.push(row2);
123852
124154
  }
123853
124155
  for (const update of plan.updates) {
123854
124156
  pathRows?.add(update.valueId);
@@ -123862,6 +124164,13 @@ var init_collection_binding_materialization = __esm({
123862
124164
  value: mergeBodies(previous.value, update.value)
123863
124165
  });
123864
124166
  }
124167
+ this.schema ??= new MaterializedValueGraphContext({
124168
+ ...this.document,
124169
+ values: []
124170
+ });
124171
+ for (const row2 of created)
124172
+ for (const targetId of this.schema.referenceArgumentIds(row2))
124173
+ if (graph.rowsById.has(targetId)) this.materialize(targetId, pathRows);
123865
124174
  return true;
123866
124175
  }
123867
124176
  };
@@ -124070,6 +124379,42 @@ var init_prepared_collection_bindings = __esm({
124070
124379
  }
124071
124380
  });
124072
124381
 
124382
+ // ../src/database/declared-binding-targets.ts
124383
+ function declaredBindingTargetIds(document) {
124384
+ const ids = /* @__PURE__ */ new Set();
124385
+ for (const member of document.members) {
124386
+ if (member.kind !== 9 /* Lookup */) continue;
124387
+ if (isMemberCollectionLookupBase(member) && typeof member.collectionValueId === "string")
124388
+ ids.add(member.collectionValueId);
124389
+ const selection2 = isLiteralValueContent(member.defaultValue) ? member.defaultValue.value : void 0;
124390
+ if (typeof selection2 === "string") ids.add(selection2);
124391
+ if (Array.isArray(selection2)) {
124392
+ for (const id2 of selection2) if (typeof id2 === "string") ids.add(id2);
124393
+ }
124394
+ }
124395
+ for (const folder of document.variantFolders ?? [])
124396
+ if (folder.binding !== void 0) ids.add(folder.binding.collectionValueId);
124397
+ for (const group of document.dialogueGroups)
124398
+ if (group.type === 1 /* Lookup */ && typeof group.collectionValueId === "string")
124399
+ ids.add(group.collectionValueId);
124400
+ const pendingIdsByRootId = /* @__PURE__ */ new Map();
124401
+ for (const id2 of ids) {
124402
+ const rootId = pendingVirtualValueIdentity(id2)?.instanceRootId;
124403
+ if (rootId === void 0) continue;
124404
+ const pending = pendingIdsByRootId.get(rootId);
124405
+ if (pending === void 0) pendingIdsByRootId.set(rootId, [id2]);
124406
+ else pending.push(id2);
124407
+ }
124408
+ return { ids, pendingIdsByRootId };
124409
+ }
124410
+ var init_declared_binding_targets = __esm({
124411
+ "../src/database/declared-binding-targets.ts"() {
124412
+ "use strict";
124413
+ init_members();
124414
+ init_member_value_id();
124415
+ }
124416
+ });
124417
+
124073
124418
  // ../src/runtime/stored-closure-captures.ts
124074
124419
  function assertStoredClosuresKeepNoCaptures(args) {
124075
124420
  for (const row of args.rows) {
@@ -127817,6 +128162,7 @@ function materializePreparedInstanceInitializers(args) {
127817
128162
  const localizedTextIds = new Set(
127818
128163
  materializationScope.document.localizedTexts.map((text) => text.id)
127819
128164
  );
128165
+ const bindingTargets = declaredBindingTargetIds(compiledDocument);
127820
128166
  const replayOnlyIndexes = [];
127821
128167
  const pendingSites = /* @__PURE__ */ new Map();
127822
128168
  for (const [valueId, site] of sites) {
@@ -127906,7 +128252,8 @@ function materializePreparedInstanceInitializers(args) {
127906
128252
  // the class default, so the evaluated construction's own field list is
127907
128253
  // what pins rows against collapse.
127908
128254
  pinnedRootSchemaKeys: materialized.pinnedRootSchemaKeys,
127909
- pinnedSchemaKeysByValueId: materialized.pinnedSchemaKeysByValueId
128255
+ pinnedSchemaKeysByValueId: materialized.pinnedSchemaKeysByValueId,
128256
+ bindingTargets
127910
128257
  });
127911
128258
  assertStoredClosuresKeepNoCaptures({
127912
128259
  sourceValueId: valueId,
@@ -131073,6 +131420,7 @@ var init_project_version_schema_commit = __esm({
131073
131420
  init_neoscript_compiler_revision();
131074
131421
  init_neoscript_source_catalog();
131075
131422
  init_prepared_collection_bindings();
131423
+ init_declared_binding_targets();
131076
131424
  init_stored_closure_captures();
131077
131425
  init_document_initializer_compiler();
131078
131426
  init_effective_value_comparison();
@@ -143486,13 +143834,6 @@ function drainValueReferenceObligationsV4(state, manifest, options) {
143486
143834
  ...composeReferenceSitePosition(move.site, options.sourceTextByUri)
143487
143835
  });
143488
143836
  }
143489
- for (const recorded of options.registry.loweringFailures) {
143490
- failures.push({
143491
- message: recorded.message,
143492
- ...recorded.code === void 0 ? {} : { code: recorded.code },
143493
- ...composeReferenceSitePosition(recorded.site, options.sourceTextByUri)
143494
- });
143495
- }
143496
143837
  for (const obligation of [
143497
143838
  ...collectionValueObligations(manifest),
143498
143839
  ...options.registry.referenceObligations
@@ -143530,7 +143871,17 @@ function drainValueReferenceObligationsV4(state, manifest, options) {
143530
143871
  ...composeReferenceSitePosition(obligation.site, options.sourceTextByUri)
143531
143872
  });
143532
143873
  }
143533
- return failures;
143874
+ const loweringFailures = options.registry.loweringFailures.map(
143875
+ (recorded) => recorded instanceof SchemaSourceError ? recorded : {
143876
+ message: recorded.message,
143877
+ ...recorded.code === void 0 ? {} : { code: recorded.code },
143878
+ ...composeReferenceSitePosition(
143879
+ recorded.site,
143880
+ options.sourceTextByUri
143881
+ )
143882
+ }
143883
+ );
143884
+ return [...loweringFailures, ...failures];
143534
143885
  }
143535
143886
  function withoutDeletedValues(state, deletedValueIds) {
143536
143887
  if (deletedValueIds.size === 0) return state;
@@ -150554,6 +150905,11 @@ function storedConstructorArgumentSource(context, type, value, environment, visi
150554
150905
  false
150555
150906
  );
150556
150907
  case "reference":
150908
+ if (typeof value !== "string") {
150909
+ throw new Error(
150910
+ "Stored Reference constructor argument is not a target id."
150911
+ );
150912
+ }
150557
150913
  return referenceValue(
150558
150914
  context,
150559
150915
  {
@@ -150561,7 +150917,7 @@ function storedConstructorArgumentSource(context, type, value, environment, visi
150561
150917
  name: "argument",
150562
150918
  kind: 9 /* Lookup */
150563
150919
  },
150564
- value,
150920
+ [value],
150565
150921
  false,
150566
150922
  storedTypeArgumentName(context, type.target, environment)
150567
150923
  );
@@ -152062,6 +152418,7 @@ var INFERRED_GENERIC_CLASS_PREFIX, MEMBER_KIND_DICTIONARY2, MEMBER_KIND_LIST2, M
152062
152418
  var init_value_sources = __esm({
152063
152419
  "src/project-source/value-sources.ts"() {
152064
152420
  "use strict";
152421
+ init_source_diagnostics();
152065
152422
  init_immutable_json3();
152066
152423
  init_lower_support();
152067
152424
  init_record_fields();
@@ -153391,6 +153748,7 @@ function materializeInitializersLocallyV4(args) {
153391
153748
  const localizedTextIds = new Set(
153392
153749
  authoredDocument.localizedTexts?.map((text) => text.id)
153393
153750
  );
153751
+ const bindingTargets = declaredBindingTargetIds(authoredDocument);
153394
153752
  const pendingRoots = new Set(
153395
153753
  [...sourceRoots].filter((id2) => rootKinds.get(id2) !== "declaration").sort()
153396
153754
  );
@@ -153587,6 +153945,7 @@ function materializeInitializersLocallyV4(args) {
153587
153945
  // pins rows against collapse. Push preparation pins the same set.
153588
153946
  pinnedRootSchemaKeys: pinned.pinnedRootSchemaKeys,
153589
153947
  pinnedSchemaKeysByValueId: pinned.pinnedSchemaKeysByValueId,
153948
+ bindingTargets,
153590
153949
  virtualValueIdForSource: (instanceRootId, sourceIdentity3) => isPendingId(instanceRootId) || hasPendingVirtualSourceIdentity(sourceIdentity3) ? pendingVirtualValueId(instanceRootId, sourceIdentity3) : virtualValueId(instanceRootId, sourceIdentity3)
153591
153950
  });
153592
153951
  const evaluatedRows = [sparse2.root, ...sparse2.createdChildren];
@@ -153783,6 +154142,7 @@ var init_local_initializer_materialization = __esm({
153783
154142
  init_inheritance();
153784
154143
  init_effective_value_reader();
153785
154144
  init_virtual_instance_values();
154145
+ init_declared_binding_targets();
153786
154146
  init_value_graph();
153787
154147
  init_pending_id();
153788
154148
  init_value_comparison();
@@ -156832,7 +157192,7 @@ function quote4(value) {
156832
157192
  function resolveRootPathCollectionValuesV4(args) {
156833
157193
  const resolved = /* @__PURE__ */ new Map();
156834
157194
  let rootValues;
156835
- let placements;
157195
+ let walk;
156836
157196
  for (const member of args.manifest.members) {
156837
157197
  if (member.kind !== "lookup") continue;
156838
157198
  const spelled = member.collectionValueId;
@@ -156854,16 +157214,9 @@ function resolveRootPathCollectionValuesV4(args) {
156854
157214
  };
156855
157215
  const target = walkRootValuePath(
156856
157216
  path,
156857
- args.state,
156858
- args.registry,
156859
- () => placements ??= prospectiveStoredValuePlacements(
156860
- args.state,
156861
- args.registry,
156862
- args.manifest
156863
- ),
157217
+ walk ??= valuePathWalk(args),
156864
157218
  rootValues,
156865
157219
  fail2,
156866
- args.resolveVirtualPath,
156867
157220
  args.unavailableSlots
156868
157221
  );
156869
157222
  if (target !== null) resolved.set(member.id, target);
@@ -156873,7 +157226,7 @@ function resolveRootPathCollectionValuesV4(args) {
156873
157226
  function resolveRootPathVariantFolderCollectionValuesV4(args) {
156874
157227
  const resolved = /* @__PURE__ */ new Map();
156875
157228
  let rootValues;
156876
- let placements;
157229
+ let walk;
156877
157230
  for (const folder of args.manifest.variantFolders) {
156878
157231
  const spelled = folder.binding?.collectionValueId;
156879
157232
  if (typeof spelled !== "string") continue;
@@ -156894,16 +157247,9 @@ function resolveRootPathVariantFolderCollectionValuesV4(args) {
156894
157247
  };
156895
157248
  const target = walkRootValuePath(
156896
157249
  path,
156897
- args.state,
156898
- args.registry,
156899
- () => placements ??= prospectiveStoredValuePlacements(
156900
- args.state,
156901
- args.registry,
156902
- args.manifest
156903
- ),
157250
+ walk ??= valuePathWalk(args),
156904
157251
  rootValues,
156905
157252
  fail2,
156906
- args.resolveVirtualPath,
156907
157253
  args.unavailableSlots
156908
157254
  );
156909
157255
  if (target !== null) resolved.set(folder.id, target);
@@ -156911,83 +157257,87 @@ function resolveRootPathVariantFolderCollectionValuesV4(args) {
156911
157257
  return resolved;
156912
157258
  }
156913
157259
  function createRootValuePathResolverV4(args) {
156914
- let placements;
157260
+ const walk = valuePathWalk(args);
156915
157261
  let rootValues;
156916
- let computed;
156917
- const readPlacements = () => placements ??= prospectiveStoredValuePlacements(
156918
- args.state,
156919
- args.registry,
156920
- args.manifest
156921
- );
156922
- const settle = (walk2) => {
157262
+ const settle = (resolve7) => {
156923
157263
  const failures = [];
156924
- const valueId = walk2((failure) => failures.push(failure));
157264
+ const valueId = resolve7((failure) => failures.push(failure));
156925
157265
  if (valueId !== null) {
156926
157266
  const stored = args.state[`value:${valueId}`] !== void 0 || args.registry.pendingValues.has(valueId);
156927
157267
  return {
156928
157268
  kind: "resolved",
156929
157269
  valueId,
156930
- memberId: readPlacements().placementByChildValueId.get(valueId)?.memberId ?? null,
157270
+ memberId: walk.placements().placementByChildValueId.get(valueId)?.memberId ?? null,
156931
157271
  ...stored ? {} : { virtual: true }
156932
157272
  };
156933
157273
  }
156934
157274
  const message = failures[0];
156935
157275
  return message === void 0 ? { kind: "unavailable" } : { kind: "failed", message };
156936
157276
  };
156937
- const walk = () => ({
156938
- state: args.state,
156939
- registry: args.registry,
156940
- placements: readPlacements,
156941
- resolveVirtualPath: args.resolveVirtualPath,
156942
- isComputed: computed ??= computedMemberTest(args.manifest)
156943
- });
156944
157277
  return {
156945
157278
  root: (path) => settle((fail2) => {
156946
157279
  if (rootValues === void 0) rootValues = rootSlotValueIds(args.state);
156947
157280
  return walkRootValuePath(
156948
157281
  path,
156949
- args.state,
156950
- args.registry,
156951
- readPlacements,
157282
+ walk,
156952
157283
  rootValues,
156953
157284
  fail2,
156954
- args.resolveVirtualPath,
156955
157285
  args.unavailableSlots,
156956
- "Index path",
156957
- walk().isComputed
157286
+ "Index path"
156958
157287
  );
156959
157288
  }),
156960
157289
  from: (valueId, segments, path) => settle(
156961
- (fail2) => walkValueSegments(walk(), valueId, segments, path, "Reference", fail2)
157290
+ (fail2) => walkValueSegments(walk, valueId, segments, path, "Reference", fail2)
156962
157291
  )
156963
157292
  };
156964
157293
  }
156965
- function computedMemberTest(manifest) {
157294
+ function valuePathWalk(args) {
157295
+ let placements;
157296
+ let schema;
157297
+ return {
157298
+ state: args.state,
157299
+ registry: args.registry,
157300
+ placements: () => placements ??= prospectiveStoredValuePlacements(
157301
+ args.state,
157302
+ args.registry,
157303
+ args.manifest
157304
+ ),
157305
+ schema: () => schema ??= manifestSchemaIndex(args.manifest),
157306
+ resolveVirtualPath: args.resolveVirtualPath,
157307
+ initBuiltSlots: args.initBuiltSlots ?? "derive"
157308
+ };
157309
+ }
157310
+ function manifestSchemaIndex(manifest) {
156966
157311
  const classes = new Map(
156967
157312
  manifest.classes.map((schemaClass2) => [schemaClass2.id, schemaClass2])
156968
157313
  );
156969
- const computed = new Set(
156970
- manifest.members.flatMap(
156971
- (member) => member.kind === "computed" ? [member.id] : []
156972
- )
157314
+ const members = new Map(
157315
+ manifest.members.map((member) => [member.id, member])
156973
157316
  );
156974
- return (valueId, name, walk) => {
156975
- const pending = walk.registry.pendingValues.get(valueId);
156976
- const stored = walk.state[`value:${valueId}`]?.data;
156977
- const classId = pending?.nodeType === "literal" ? pending.classId : isObjectRecord(stored) ? stored.classId : void 0;
156978
- const visited = /* @__PURE__ */ new Set();
156979
- let cursor = typeof classId === "string" ? classes.get(classId) : void 0;
156980
- while (cursor !== void 0 && !visited.has(cursor.id)) {
156981
- visited.add(cursor.id);
156982
- const memberId = cursor.schema[name];
156983
- if (memberId !== void 0) return computed.has(memberId);
156984
- cursor = cursor.extendsClassId === null || cursor.extendsClassId === void 0 ? void 0 : classes.get(cursor.extendsClassId);
157317
+ return {
157318
+ member: (memberId) => members.get(memberId),
157319
+ schemaMember: (classId, schemaKey) => {
157320
+ const visited = /* @__PURE__ */ new Set();
157321
+ let cursor = classes.get(classId);
157322
+ while (cursor !== void 0 && !visited.has(cursor.id)) {
157323
+ visited.add(cursor.id);
157324
+ const memberId = cursor.schema[schemaKey];
157325
+ if (memberId !== void 0) return members.get(memberId);
157326
+ cursor = cursor.extendsClassId === null ? void 0 : classes.get(cursor.extendsClassId);
157327
+ }
157328
+ return void 0;
156985
157329
  }
156986
- return false;
156987
157330
  };
156988
157331
  }
157332
+ function isComputedMember(walk, valueId, name) {
157333
+ const pending = walk.registry.pendingValues.get(valueId);
157334
+ const stored = walk.state[`value:${valueId}`]?.data;
157335
+ const storedClassId = isObjectRecord(stored) ? stored.classId : void 0;
157336
+ const classId = pending?.nodeType === "literal" ? pending.classId : storedClassId;
157337
+ return typeof classId === "string" && walk.schema().schemaMember(classId, name)?.kind === "computed";
157338
+ }
156989
157339
  function resolveRootPathDialogueGroupCollectionValuesV4(args) {
156990
- let placements;
157340
+ let walk;
156991
157341
  let rootValues;
156992
157342
  for (const record7 of args.records) {
156993
157343
  if (record7.recordKind !== "dialogue-group") continue;
@@ -156997,13 +157347,7 @@ function resolveRootPathDialogueGroupCollectionValuesV4(args) {
156997
157347
  if (rootValues === void 0) rootValues = rootSlotValueIds(args.state);
156998
157348
  const target = walkRootValuePath(
156999
157349
  spelled.slice(ROOT_PATH_PENDING_PREFIX.length),
157000
- args.state,
157001
- args.registry,
157002
- () => placements ??= prospectiveStoredValuePlacements(
157003
- args.state,
157004
- args.registry,
157005
- args.manifest
157006
- ),
157350
+ walk ??= valuePathWalk(args),
157007
157351
  rootValues,
157008
157352
  (message) => args.registry.loweringFailures.push({
157009
157353
  message,
@@ -157017,7 +157361,6 @@ function resolveRootPathDialogueGroupCollectionValuesV4(args) {
157017
157361
  label: String(record7.fileFields.name)
157018
157362
  }
157019
157363
  }),
157020
- args.resolveVirtualPath,
157021
157364
  args.unavailableSlots
157022
157365
  );
157023
157366
  if (target !== null) record7.fileFields.collectionValueId = target;
@@ -157036,7 +157379,7 @@ function rootSlotValueIds(state) {
157036
157379
  }
157037
157380
  return values;
157038
157381
  }
157039
- function walkRootValuePath(path, state, registry, placements, rootValues, fail2, resolveVirtualPath, unavailableSlots, subject = "collectionValue path", isComputed) {
157382
+ function walkRootValuePath(path, walk, rootValues, fail2, unavailableSlots, subject = "collectionValue path") {
157040
157383
  const segments = path.split(".");
157041
157384
  const slotName = segments[1];
157042
157385
  if (segments[0] !== "root" || slotName === void 0) {
@@ -157063,7 +157406,7 @@ function walkRootValuePath(path, state, registry, placements, rootValues, fail2,
157063
157406
  return null;
157064
157407
  }
157065
157408
  return walkValueSegments(
157066
- { state, registry, placements, resolveVirtualPath, isComputed },
157409
+ walk,
157067
157410
  slotValueId,
157068
157411
  segments.slice(2),
157069
157412
  path,
@@ -157073,7 +157416,7 @@ function walkRootValuePath(path, state, registry, placements, rootValues, fail2,
157073
157416
  }
157074
157417
  function walkValueSegments(walk, startId, segments, path, subject, fail2) {
157075
157418
  let cursor = startId;
157076
- for (const segment of segments) {
157419
+ for (const [index, segment] of segments.entries()) {
157077
157420
  const pending = walk.registry.pendingValues.get(cursor);
157078
157421
  const body = (pending?.nodeType === "literal" ? pending.value : void 0) ?? (isObjectRecord(walk.state[`value:${cursor}`]?.data) ? (walk.state[`value:${cursor}`]?.data).value : void 0);
157079
157422
  if (Array.isArray(body)) {
@@ -157084,12 +157427,21 @@ function walkValueSegments(walk, startId, segments, path, subject, fail2) {
157084
157427
  }
157085
157428
  if (!isObjectRecord(body)) {
157086
157429
  const initializer = pending !== void 0 ? pending.nodeType === "initializer" : isInitValueContent(walk.state[`value:${cursor}`]?.data);
157087
- if (initializer) {
157430
+ if (initializer && walk.initBuiltSlots === "refuse") {
157088
157431
  fail2(
157089
- `${subject} ${path} stops before segment ${segment}: an init block constructs the row it reaches, so a path cannot name its members yet.`
157432
+ `${subject} ${path} stops before segment ${segment}: an init block constructs the row it reaches, so a value cannot name its members. Bind it from a declaration instead.`
157090
157433
  );
157091
157434
  return null;
157092
157435
  }
157436
+ if (initializer)
157437
+ return constructedSlotId(
157438
+ walk,
157439
+ cursor,
157440
+ segments.slice(index),
157441
+ path,
157442
+ subject,
157443
+ fail2
157444
+ );
157093
157445
  fail2(
157094
157446
  `${subject} ${path} stops before segment ${segment}: the row it reaches stores no single-valued members.`
157095
157447
  );
@@ -157101,7 +157453,7 @@ function walkValueSegments(walk, startId, segments, path, subject, fail2) {
157101
157453
  const direct = directBody && typeof bodyId === "string" && (walk.registry.pendingValues.has(bodyId) || storedChild?.recordKind === "value" && storedChild.recordId === bodyId && isObjectRecord(storedChild.data));
157102
157454
  const next = direct ? bodyId : walk.placements().childrenByParentValueId.get(cursor)?.get(segment)?.childValueId;
157103
157455
  if (typeof next !== "string") {
157104
- if (walk.isComputed?.(cursor, segment, walk) === true) {
157456
+ if (isComputedMember(walk, cursor, segment)) {
157105
157457
  fail2(
157106
157458
  `\`${path}\` names a computed member, which has no row to reference.`
157107
157459
  );
@@ -157111,6 +157463,10 @@ function walkValueSegments(walk, startId, segments, path, subject, fail2) {
157111
157463
  const resolved = walk.resolveVirtualPath?.(startId, segments);
157112
157464
  if (resolved != null) return resolved;
157113
157465
  } catch (error) {
157466
+ if (error instanceof SchemaSourceError) {
157467
+ walk.registry.loweringFailures.push(error);
157468
+ return null;
157469
+ }
157114
157470
  fail2(
157115
157471
  `${subject} ${path} could not resolve its construction: ${error instanceof Error ? error.message : String(error)}`
157116
157472
  );
@@ -157125,6 +157481,66 @@ function walkValueSegments(walk, startId, segments, path, subject, fail2) {
157125
157481
  }
157126
157482
  return cursor;
157127
157483
  }
157484
+ function constructedSlotId(walk, rootId, segments, path, subject, fail2) {
157485
+ const schema = walk.schema();
157486
+ const placement = walk.placements().placementByChildValueId.get(rootId);
157487
+ if (placement === void 0) {
157488
+ fail2(
157489
+ `${subject} ${path} reaches init-built row ${rootId}, which no row places.`
157490
+ );
157491
+ return null;
157492
+ }
157493
+ const rootMemberId = placement.memberId;
157494
+ if (rootMemberId === null) {
157495
+ fail2(
157496
+ `${subject} ${path} reaches init-built row ${rootId}, which its parent's class declares no member for.`
157497
+ );
157498
+ return null;
157499
+ }
157500
+ let member = schema.member(rootMemberId);
157501
+ const steps = [];
157502
+ for (const segment of segments) {
157503
+ if (member?.kind !== "class") {
157504
+ fail2(
157505
+ `${subject} ${path} stops before segment ${segment}: the row an init block builds there stores no single-valued members.`
157506
+ );
157507
+ return null;
157508
+ }
157509
+ const slot = schema.schemaMember(member.classId, segment);
157510
+ if (slot === void 0) {
157511
+ fail2(
157512
+ `${subject} ${path} has no value at segment ${segment}: class ${member.classId} declares no such member.`
157513
+ );
157514
+ return null;
157515
+ }
157516
+ if (slot.kind === "computed") {
157517
+ fail2(
157518
+ `\`${path}\` names a computed member, which has no row to reference.`
157519
+ );
157520
+ return null;
157521
+ }
157522
+ steps.push({ schemaKey: segment, memberId: slot.id });
157523
+ member = slot;
157524
+ }
157525
+ if (member !== void 0 && hasRowTargetKind(member)) {
157526
+ fail2(
157527
+ `${subject} ${path} names a ${member.kind} an init block builds, which has no row to check against until the push stores it.`
157528
+ );
157529
+ return null;
157530
+ }
157531
+ return constructedSlotValueId(rootId, steps);
157532
+ }
157533
+ function hasRowTargetKind(member) {
157534
+ switch (member.kind) {
157535
+ case "class":
157536
+ case "list":
157537
+ case "set":
157538
+ case "dictionary":
157539
+ return true;
157540
+ default:
157541
+ return false;
157542
+ }
157543
+ }
157128
157544
  function prospectiveStoredValuePlacements(state, registry, manifest) {
157129
157545
  const records3 = new Map(
157130
157546
  Object.values(state).map((record7) => [
@@ -157185,9 +157601,11 @@ var ROOT_PROJECT_FIELDS2, ROOT_PATH_PENDING_PREFIX;
157185
157601
  var init_root_source = __esm({
157186
157602
  "src/project-source/root-source.ts"() {
157187
157603
  "use strict";
157604
+ init_source_diagnostics();
157188
157605
  init_project_root();
157189
157606
  init_value_comparison();
157190
157607
  init_members();
157608
+ init_virtual_instance_graph();
157191
157609
  init_value_sources();
157192
157610
  init_source_format();
157193
157611
  init_stored_value_placements();
@@ -160362,30 +160780,47 @@ function computeStatus(workspace, options, conflictedFiles, parseErrors, parseWa
160362
160780
  [...staticValues.records, ...memberDefaults.records, ...rootValues.records],
160363
160781
  staticMemberValueIds
160364
160782
  );
160783
+ const sourceTextByUri = new Map(
160784
+ sourceEntries.map((entry) => [entry.relPath, entry.source])
160785
+ );
160365
160786
  let collectionBindings;
160366
160787
  const resolveVirtualPath = (rootId, segments) => {
160367
- if (collectionBindings === void 0) {
160368
- const candidate = /* @__PURE__ */ new Map();
160369
- for (const [key, record7] of Object.entries(rootPathResolutionState)) {
160370
- if (record7.file !== void 0 && isSchemaRecordKindV4(record7.recordKind) && !documentsByKey.has(key))
160371
- continue;
160372
- candidate.set(key, { ...record7, deleted: false });
160373
- }
160374
- for (const row of valueLowerRegistry.pendingValues.values()) {
160375
- candidate.set(`value:${row.id}`, {
160376
- recordKind: "value",
160377
- recordId: row.id,
160378
- contentHash: "",
160379
- deleted: false,
160380
- data: { id: row.id, ...encodeStoredValueRowFields(row) }
160381
- });
160788
+ if (collectionBindings instanceof SchemaSourceError)
160789
+ throw collectionBindings;
160790
+ try {
160791
+ if (collectionBindings === void 0) {
160792
+ const candidate = /* @__PURE__ */ new Map();
160793
+ for (const [key, record7] of Object.entries(rootPathResolutionState)) {
160794
+ if (record7.file !== void 0 && isSchemaRecordKindV4(record7.recordKind) && !documentsByKey.has(key))
160795
+ continue;
160796
+ candidate.set(key, { ...record7, deleted: false });
160797
+ }
160798
+ for (const row of valueLowerRegistry.pendingValues.values()) {
160799
+ candidate.set(`value:${row.id}`, {
160800
+ recordKind: "value",
160801
+ recordId: row.id,
160802
+ contentHash: "",
160803
+ deleted: false,
160804
+ data: { id: row.id, ...encodeStoredValueRowFields(row) }
160805
+ });
160806
+ }
160807
+ const document = readPulledProjectDocumentV4(candidate);
160808
+ compilePulledProjectDocumentForEvaluationV4(document);
160809
+ collectionBindings = new CollectionBindingMaterializer(document);
160382
160810
  }
160383
- const document = readPulledProjectDocumentV4(candidate);
160384
- compilePulledProjectDocumentForEvaluationV4(document);
160385
- collectionBindings = new CollectionBindingMaterializer(document);
160811
+ const resolved = collectionBindings.resolvePath(rootId, segments);
160812
+ return resolved;
160813
+ } catch (error) {
160814
+ const diagnostic = initializerRuntimeDiagnostic(
160815
+ error,
160816
+ valueLowerRegistry.initializerSites,
160817
+ sourceTextByUri,
160818
+ projectAnalysisV4
160819
+ );
160820
+ if (!hasAuthoredSourceFile(diagnostic.file)) throw error;
160821
+ if (collectionBindings === void 0) collectionBindings = diagnostic;
160822
+ throw diagnostic;
160386
160823
  }
160387
- const resolved = collectionBindings.resolvePath(rootId, segments);
160388
- return resolved;
160389
160824
  };
160390
160825
  const resolvedCollectionPaths = resolveRootPathCollectionValuesV4({
160391
160826
  manifest,
@@ -160470,7 +160905,8 @@ function computeStatus(workspace, options, conflictedFiles, parseErrors, parseWa
160470
160905
  state: rootPathResolutionState,
160471
160906
  resolveVirtualPath,
160472
160907
  unavailableSlots: rootValues.unavailableSlots,
160473
- registry: valueLowerRegistry
160908
+ registry: valueLowerRegistry,
160909
+ initBuiltSlots: "derive"
160474
160910
  });
160475
160911
  const resolvedDefaultKeys = resolveKeyReferenceMemberDefaultsV4({
160476
160912
  manifest,
@@ -160568,7 +161004,7 @@ function computeStatus(workspace, options, conflictedFiles, parseErrors, parseWa
160568
161004
  unavailableSlots: rootValues.unavailableSlots,
160569
161005
  registry: valueLowerRegistry
160570
161006
  });
160571
- if (collectionBindings !== void 0) {
161007
+ if (collectionBindings !== void 0 && !(collectionBindings instanceof SchemaSourceError)) {
160572
161008
  const bindings = collectionBindings;
160573
161009
  const templateInitializer = (id2) => {
160574
161010
  const sourceValueId = bindings.rowForValue(id2)?.sourceValueId;
@@ -160808,9 +161244,6 @@ function computeStatus(workspace, options, conflictedFiles, parseErrors, parseWa
160808
161244
  changes.push(recordDeleteChange(recordState, recordFile));
160809
161245
  }
160810
161246
  appendCollectionEntryDeletes(workspace, reconstructed3, changes);
160811
- const sourceTextByUri = new Map(
160812
- sourceEntries.map((entry) => [entry.relPath, entry.source])
160813
- );
160814
161247
  const referenceFailures = drainValueReferenceObligationsV4(
160815
161248
  prospectiveState,
160816
161249
  manifest,
@@ -160828,11 +161261,16 @@ function computeStatus(workspace, options, conflictedFiles, parseErrors, parseWa
160828
161261
  state: rootPathResolutionState,
160829
161262
  resolveVirtualPath,
160830
161263
  unavailableSlots: rootValues.unavailableSlots,
160831
- registry: valueLowerRegistry
161264
+ registry: valueLowerRegistry,
161265
+ initBuiltSlots: "refuse"
160832
161266
  })
160833
161267
  }
160834
161268
  );
160835
161269
  for (const failure of referenceFailures) {
161270
+ if (failure instanceof SchemaSourceError) {
161271
+ parseErrors.push(failure);
161272
+ continue;
161273
+ }
160836
161274
  const message = failure.code === void 0 ? failure.message : `${failure.code}: ${failure.message}`;
160837
161275
  parseErrors.push(
160838
161276
  new SchemaSourceError(
@@ -160846,7 +161284,11 @@ function computeStatus(workspace, options, conflictedFiles, parseErrors, parseWa
160846
161284
  }
160847
161285
  reportPhase("record-diff-references", "Checking packed values\u2026");
160848
161286
  if (referenceFailures.length > 0) {
160849
- return refusedStatus(conflictedFiles, parseErrors, parseWarnings);
161287
+ return refusedStatus(
161288
+ conflictedFiles,
161289
+ uniqueSourceErrors(parseErrors),
161290
+ parseWarnings
161291
+ );
160850
161292
  }
160851
161293
  if (valueLowerRegistry.initializerKeyPatches.size > 0) {
160852
161294
  authoredValueSeeds = settleInitializerKeyCode({
@@ -167475,9 +167917,10 @@ function completionItemsForResolution(snapshot, resolved, word) {
167475
167917
  }
167476
167918
  const memberType2 = neoScriptMemberLookupType(resolved.type);
167477
167919
  const owner = memberType2.kind === "named" ? snapshot.project.typeById.get(memberType2.typeId) : void 0;
167478
- return membersForType(snapshot, resolved.type).filter(
167479
- (symbol) => (resolved.symbol?.name !== "base" || isConcreteBaseMember(symbol)) && (owner === void 0 || isMemberCompletionAccessible(snapshot, owner, symbol))
167480
- ).map((symbol) => symbolCompletion(symbol, word, snapshot));
167920
+ return membersForType(snapshot, resolved.type).filter((symbol) => {
167921
+ const declaration = symbol.inheritedFrom === void 0 ? owner : snapshot.project.typeById.get(symbol.inheritedFrom.typeId) ?? owner;
167922
+ return (resolved.symbol?.name !== "base" || isConcreteBaseMember(symbol)) && (declaration === void 0 || isMemberCompletionAccessible(snapshot, declaration, symbol));
167923
+ }).map((symbol) => symbolCompletion(symbol, word, snapshot));
167481
167924
  }
167482
167925
  function isConcreteBaseMember(symbol) {
167483
167926
  return !symbol.id.startsWith("builtin:") && symbol.static !== true && symbol.abstract !== true && (symbol.kind === "function" || symbol.kind === "method" || symbol.computed === true);
@@ -167537,6 +167980,22 @@ function membersForType(snapshot, type) {
167537
167980
  } : {}
167538
167981
  };
167539
167982
  });
167983
+ if (type.narrowedInterfaces) {
167984
+ const names = new Set(members.map((member) => member.name));
167985
+ for (const bound of Object.values(type.narrowedInterfaces)) {
167986
+ for (const member of membersForType(snapshot, bound)) {
167987
+ if (names.has(member.name)) continue;
167988
+ names.add(member.name);
167989
+ const owner = snapshot.project.typeById.get(bound.typeId);
167990
+ members.push(
167991
+ owner === void 0 || member.inheritedFrom !== void 0 ? member : {
167992
+ ...member,
167993
+ inheritedFrom: { typeId: owner.id, typeName: owner.name }
167994
+ }
167995
+ );
167996
+ }
167997
+ }
167998
+ }
167540
167999
  if (named.kind === "class") {
167541
168000
  members = members.filter(
167542
168001
  (member) => member.name !== NEOSCRIPT_CLASS_ID_MEMBER
@@ -186224,16 +186683,17 @@ function generateInheritedPropertyInterfaceAdapters(ctx, classDef, genericEnv) {
186224
186683
  continue;
186225
186684
  }
186226
186685
  const source = `((${receiverType})this).${memberName}`;
186227
- const getter = isMemberWithEntries(member) && interfaceValueType.startsWith("NeoReadOnly") ? readExpression(
186686
+ const getter = isMemberWithEntries(member) ? collectionReadExpression(
186228
186687
  ctx,
186229
186688
  member,
186689
+ `node.Get<${neoMemberNodeType(member)}>("${escapeCSharpString(schemaKey)}")`,
186230
186690
  schemaKey,
186231
- neoMemberNodeType(member),
186232
- false,
186233
- receiverType,
186691
+ resolveMemberById(ctx, member.entryMemberId, "entryMemberId"),
186692
+ memberSavedForStorage(ctx, memberId, false, declarationClass.id),
186234
186693
  null,
186235
186694
  genericEnv,
186236
- declarationClass.id
186695
+ interfaceValueType,
186696
+ false
186237
186697
  ) : [`return (${interfaceValueType})(object)${source}!;`];
186238
186698
  const hasSetter = isMemberNSPropertyBase(member) && typeof member.setterCode === "string";
186239
186699
  const adapter = [
@@ -190755,12 +191215,12 @@ function collectionGuardArguments(member, writeGuardMemberName) {
190755
191215
  const name = escapeCSharpString(writeGuardMemberName);
190756
191216
  return isReadOnlyMember(member) ? `, () => ThrowReadOnlyMembership("${name}"), () => true` : `, () => ThrowIfReadOnly("${name}"), () => IsReadOnly`;
190757
191217
  }
190758
- function collectionReadExpression(ctx, member, getNode, schemaKey, entryMember, saved, writeGuardMemberName, genericEnv, collectionTypeOverride) {
191218
+ function collectionReadExpression(ctx, member, getNode, schemaKey, entryMember, saved, writeGuardMemberName, genericEnv, collectionTypeOverride, genericBindingSaved = saved) {
190759
191219
  const keyCodecArguments = dictionaryKeyCodecArguments(ctx, member);
190760
191220
  if (saved) {
190761
191221
  const entrySaved = collectionEntrySaved(member, entryMember, true);
190762
191222
  const writableNodeType = isMemberDictionaryBase(member) ? "NeoMemberDictionaryWritable" : "NeoMemberListWritable";
190763
- const collectionType2 = collectionTypeOverride ?? csharpValueType(ctx, member, true, genericEnv);
191223
+ const collectionType2 = collectionTypeOverride ?? csharpValueType(ctx, member, true, genericEnv, genericBindingSaved);
190764
191224
  const keyLiteral = `"${escapeCSharpString(schemaKey)}"`;
190765
191225
  const readNode = `writableNode.Get<${writableNodeType}>(${keyLiteral})`;
190766
191226
  const guardArguments = collectionGuardArguments(
@@ -190772,13 +191232,14 @@ function collectionReadExpression(ctx, member, getNode, schemaKey, entryMember,
190772
191232
  entryMember,
190773
191233
  readNode,
190774
191234
  member.name,
190775
- genericEnv
191235
+ genericEnv,
191236
+ genericBindingSaved
190776
191237
  );
190777
191238
  return cachedStoredWrapper(
190778
191239
  schemaKey,
190779
191240
  readNode,
190780
191241
  collectionType2 ?? "object",
190781
- `new ${collectionType2}(client, memberNode, () => writableNode.GetOrCreateCollection<${writableNodeType}>(${keyLiteral}), (client, child) => ${childConverter(ctx, entryMember, entrySaved, entrySaved && writeGuardMemberName != null, genericEnv)}, item => ${serializeExpression}${keyCodecArguments}${guardArguments})`
191242
+ `new ${collectionType2}(client, memberNode, () => writableNode.GetOrCreateCollection<${writableNodeType}>(${keyLiteral}), (client, child) => ${childConverter(ctx, entryMember, entrySaved, entrySaved && writeGuardMemberName != null, genericEnv, genericBindingSaved)}, item => ${serializeExpression}${keyCodecArguments}${guardArguments})`
190782
191243
  );
190783
191244
  }
190784
191245
  const collectionType = collectionTypeOverride ?? csharpValueType(ctx, member, false, genericEnv);
@@ -190900,9 +191361,9 @@ function interfaceValueRead(ctx, member, nodeExpression, readOnly, genericEnv) {
190900
191361
  if (!isRequiredMember(member)) return read;
190901
191362
  return `${read} ?? throw new InvalidOperationException("Required '${escapeCSharpString(member.name)}' holds no class value.")`;
190902
191363
  }
190903
- function entrySerializeExpression(ctx, entryMember, collectionNode, slotLabel2, genericEnv) {
191364
+ function entrySerializeExpression(ctx, entryMember, collectionNode, slotLabel2, genericEnv, genericBindingSaved = true) {
190904
191365
  const throughCodec = entryMember !== null && (isMemberGenericBase(entryMember) || isMemberLookupBase(entryMember) && lookupProjection(ctx, entryMember) !== "class" /* Class */);
190905
- return throughCodec ? `NeoGenericBindings.Resolve<${csharpValueType(ctx, entryMember, true, genericEnv) ?? "object"}>(client, ${collectionNode}).Serialize(item)` : serializeItemExpression(ctx, entryMember, "item", slotLabel2);
191366
+ return throughCodec ? `NeoGenericBindings.Resolve<${csharpValueType(ctx, entryMember, true, genericEnv, genericBindingSaved) ?? "object"}>(client, ${collectionNode}).Serialize(item)` : serializeItemExpression(ctx, entryMember, "item", slotLabel2);
190906
191367
  }
190907
191368
  function lookupSelectionFactory(ctx, member, selection2, saved, writeGuardMemberName, genericEnv) {
190908
191369
  const targetSaved = lookupTargetSaved(ctx, member) ?? saved;
@@ -191018,7 +191479,7 @@ function dialogueLookupReadExpression(member, getNode, saved, writeGuardMemberNa
191018
191479
  "return selected is null ? null : new NeoDialogueReference(client, selected);"
191019
191480
  ];
191020
191481
  }
191021
- function childConverter(ctx, member, saved = false, branchOnReadOnly = false, genericEnv) {
191482
+ function childConverter(ctx, member, saved = false, branchOnReadOnly = false, genericEnv, genericBindingSaved = saved) {
191022
191483
  if (member === null) return "throw new NotSupportedException()";
191023
191484
  if (isMemberDelegateBase(member)) {
191024
191485
  const delegateType = csharpDelegateType(ctx, member, saved, genericEnv) ?? "NeoDelegate<object?>";
@@ -191040,7 +191501,13 @@ function childConverter(ctx, member, saved = false, branchOnReadOnly = false, ge
191040
191501
  return `((NeoMemberAction)child).Bind${actionBindTypeArguments(actionType)}()`;
191041
191502
  }
191042
191503
  if (isMemberGenericBase(member)) {
191043
- const paramType = csharpValueType(ctx, member, saved, genericEnv);
191504
+ const paramType = csharpValueType(
191505
+ ctx,
191506
+ member,
191507
+ saved,
191508
+ genericEnv,
191509
+ genericBindingSaved
191510
+ );
191044
191511
  if (paramType === null) return "throw new NotSupportedException()";
191045
191512
  return `NeoGenericBindings.Resolve<${paramType}>(client, (NeoMember)child).Read((NeoMember)child)`;
191046
191513
  }
@@ -194671,7 +195138,7 @@ var UNITY_CODEGEN_REVISION;
194671
195138
  var init_unity_codegen_revision = __esm({
194672
195139
  "../src/models/exports/unity-codegen-revision.ts"() {
194673
195140
  "use strict";
194674
- UNITY_CODEGEN_REVISION = "231557c5a40a20ab9e630415d45556845d7561d54e335a4d92c1cdbc1024a705";
195141
+ UNITY_CODEGEN_REVISION = "e875228ee779f868c2c818eb9e245604cd074598712ffd3f8394f460317b1a28";
194675
195142
  }
194676
195143
  });
194677
195144
 
@@ -215809,7 +216276,7 @@ var releaseWorkspaceLock = () => void 0;
215809
216276
  async function main() {
215810
216277
  const args = parseArgs(process.argv.slice(2));
215811
216278
  if (args.command === "--version") {
215812
- console.log("0.84.1");
216279
+ console.log("0.84.3");
215813
216280
  return;
215814
216281
  }
215815
216282
  if (args.command === null || args.command === "help" || args.command === "--help" || args.command === "-h") {