@geastack/compiler 1.0.32 → 1.0.34

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.
Files changed (210) hide show
  1. package/README.md +1 -1
  2. package/dist/cli-coverage.js +2 -4
  3. package/dist/cli-emit.js +1 -1
  4. package/dist/cli-module-graph.js +1 -1
  5. package/dist/cli.js +2 -1
  6. package/dist/compiler.js +35 -28
  7. package/dist/conversion/array-view.js +9 -0
  8. package/dist/conversion/build.js +15 -8
  9. package/dist/conversion/dictionary-view.js +2 -2
  10. package/dist/conversion/nodes.d.ts +7 -0
  11. package/dist/conversion/nodes.js +58 -11
  12. package/dist/identity/ids.d.ts +4 -0
  13. package/dist/identity/ids.js +4 -0
  14. package/dist/ir/build.d.ts +4 -3
  15. package/dist/ir/build.js +14 -5
  16. package/dist/ir/call-dispatch.js +67 -7
  17. package/dist/ir/call-entry.js +1 -1
  18. package/dist/ir/callable-class-flow.d.ts +4 -0
  19. package/dist/ir/callable-class-flow.js +123 -1
  20. package/dist/ir/certify/parallel-region.js +698 -20
  21. package/dist/ir/certify.d.ts +3 -0
  22. package/dist/ir/certify.js +44 -9
  23. package/dist/ir/class-allocation-domain.js +2 -2
  24. package/dist/ir/class-construction-status.d.ts +10 -0
  25. package/dist/ir/class-construction-status.js +36 -0
  26. package/dist/ir/convert-carriers.d.ts +10 -1
  27. package/dist/ir/convert-carriers.js +18 -1
  28. package/dist/ir/dynamic-constructor-conversions.js +4 -2
  29. package/dist/ir/finite-iterator-close.d.ts +14 -0
  30. package/dist/ir/finite-iterator-close.js +50 -0
  31. package/dist/ir/host-template-conversions.js +9 -0
  32. package/dist/ir/lower-allocation.js +1 -1
  33. package/dist/ir/lower-flow.js +24 -3
  34. package/dist/ir/lower-operands.js +88 -7
  35. package/dist/ir/lower-protocol.js +1 -1
  36. package/dist/ir/lower.js +22 -6
  37. package/dist/ir/model.d.ts +41 -1
  38. package/dist/ir/native-accessor-definition.d.ts +3 -2
  39. package/dist/ir/native-accessor-definition.js +29 -10
  40. package/dist/ir/native-array-transport.js +2 -2
  41. package/dist/ir/native-field-view-domains.d.ts +23 -0
  42. package/dist/ir/native-field-view-domains.js +115 -9
  43. package/dist/ir/native-field-view-facts.d.ts +46 -2
  44. package/dist/ir/native-field-view-facts.js +159 -4
  45. package/dist/ir/native-iterable.d.ts +17 -0
  46. package/dist/ir/native-iterable.js +72 -0
  47. package/dist/ir/native-key-query.js +1 -1
  48. package/dist/ir/operation-conversions.js +15 -3
  49. package/dist/ir/program-conversions.js +2 -2
  50. package/dist/ir/publish-native-field-view-facts.js +9 -4
  51. package/dist/ir/pure-conversion-reuse.d.ts +58 -0
  52. package/dist/ir/pure-conversion-reuse.js +263 -0
  53. package/dist/ir/queries.js +1 -0
  54. package/dist/ir/reflection-demand.js +70 -18
  55. package/dist/ir/shake.js +2 -2
  56. package/dist/ir/unobserved-callable-inputs.d.ts +37 -0
  57. package/dist/ir/unobserved-callable-inputs.js +111 -0
  58. package/dist/native-signatures.d.ts +1 -1
  59. package/dist/native-signatures.js +27 -2
  60. package/dist/plugins/gea/component-classes.d.ts +2 -1
  61. package/dist/plugins/gea/component-classes.js +3 -3
  62. package/dist/plugins/gea/contract.d.ts +26 -3
  63. package/dist/plugins/gea/contract.js +42 -43
  64. package/dist/plugins/gea/host.d.ts +9 -0
  65. package/dist/plugins/gea/host.js +25 -4
  66. package/dist/plugins/gea/plugin.js +12 -6
  67. package/dist/plugins/gea/producer.d.ts +2 -2
  68. package/dist/plugins/gea/producer.js +2 -2
  69. package/dist/plugins/load.js +18 -1
  70. package/dist/plugins/model.d.ts +5 -0
  71. package/dist/plugins/native-iterable-providers.d.ts +18 -0
  72. package/dist/plugins/native-iterable-providers.js +51 -0
  73. package/dist/project-preparation.d.ts +8 -0
  74. package/dist/project-preparation.js +49 -7
  75. package/dist/projection/bindings.d.ts +13 -0
  76. package/dist/projection/bindings.js +20 -1
  77. package/dist/projection/classes.d.ts +4 -2
  78. package/dist/projection/classes.js +12 -5
  79. package/dist/representation/collections.js +2 -0
  80. package/dist/representation/derive.js +1 -0
  81. package/dist/representation/model.d.ts +2 -0
  82. package/dist/representation/model.js +1 -0
  83. package/dist/representation/policies.d.ts +2 -0
  84. package/dist/representation/primitive-domain.d.ts +1 -1
  85. package/dist/representation/primitive-domain.js +1 -1
  86. package/dist/representation/unassigned-binding-cells.d.ts +4 -3
  87. package/dist/representation/unassigned-binding-cells.js +19 -2
  88. package/dist/representation/union.js +6 -6
  89. package/dist/semantics/frontend.d.ts +2 -0
  90. package/dist/semantics/frontend.js +34 -5
  91. package/dist/semantics/host-methods.js +4 -1
  92. package/dist/semantics/jsx-runtime-provider.d.ts +5 -0
  93. package/dist/semantics/jsx-runtime-provider.js +16 -0
  94. package/dist/semantics/model/native-iterable.d.ts +14 -0
  95. package/dist/semantics/model/native-iterable.js +7 -0
  96. package/dist/semantics/model/operands.d.ts +30 -0
  97. package/dist/semantics/model/operations.d.ts +15 -0
  98. package/dist/semantics/model/primitive-domain.d.ts +15 -0
  99. package/dist/semantics/model/primitive-domain.js +27 -4
  100. package/dist/semantics/module-resolution.js +13 -2
  101. package/dist/semantics/normalize/any-cast-member-call.d.ts +1 -1
  102. package/dist/semantics/normalize/callback-parameter-contracts.d.ts +32 -4
  103. package/dist/semantics/normalize/callback-parameter-contracts.js +66 -6
  104. package/dist/semantics/normalize/census.d.ts +3 -0
  105. package/dist/semantics/normalize/census.js +17 -12
  106. package/dist/semantics/normalize/deferred-intrinsic-protocols.d.ts +4 -1
  107. package/dist/semantics/normalize/deferred-intrinsic-protocols.js +29 -9
  108. package/dist/semantics/normalize/flow/callable-reach.js +94 -3
  109. package/dist/semantics/normalize/flow/component-solver.js +144 -55
  110. package/dist/semantics/normalize/flow/member-call-forwarding.d.ts +9 -0
  111. package/dist/semantics/normalize/flow/member-call-forwarding.js +30 -4
  112. package/dist/semantics/normalize/flow/proof-hypotheses.d.ts +2 -0
  113. package/dist/semantics/normalize/flow/proof-hypotheses.js +27 -0
  114. package/dist/semantics/normalize/flow/source-callable-own-data.js +87 -14
  115. package/dist/semantics/normalize/flow/source-commonjs-exports.d.ts +2 -0
  116. package/dist/semantics/normalize/flow/source-commonjs-exports.js +2 -0
  117. package/dist/semantics/normalize/flow/source-native-iterable-integrity.d.ts +17 -0
  118. package/dist/semantics/normalize/flow/source-native-iterable-integrity.js +125 -0
  119. package/dist/semantics/normalize/flow/source-native-origin.d.ts +6 -0
  120. package/dist/semantics/normalize/flow/source-native-origin.js +38 -0
  121. package/dist/semantics/normalize/flow/source-proxy-operation.d.ts +37 -0
  122. package/dist/semantics/normalize/flow/source-proxy-operation.js +201 -0
  123. package/dist/semantics/normalize/flow/source-raw-constructor-entry.d.ts +20 -0
  124. package/dist/semantics/normalize/flow/source-raw-constructor-entry.js +73 -0
  125. package/dist/semantics/normalize/flow/source-value-session.d.ts +50 -1
  126. package/dist/semantics/normalize/flow/source-value-session.js +596 -57
  127. package/dist/semantics/normalize/flow/value-flow.d.ts +17 -0
  128. package/dist/semantics/normalize/flow/value-flow.js +84 -0
  129. package/dist/semantics/normalize/fresh-dictionary-storage.js +2 -2
  130. package/dist/semantics/normalize/fresh-table-last-use.d.ts +52 -0
  131. package/dist/semantics/normalize/fresh-table-last-use.js +129 -0
  132. package/dist/semantics/normalize/gating.js +5 -1
  133. package/dist/semantics/normalize/global-host-mutations.js +190 -13
  134. package/dist/semantics/normalize/identities.js +20 -1
  135. package/dist/semantics/normalize/local-bindings.js +2 -2
  136. package/dist/semantics/normalize/parameter-bindings.js +10 -1
  137. package/dist/semantics/normalize/producer-context.d.ts +5 -0
  138. package/dist/semantics/normalize/producers/binding-kind.js +2 -0
  139. package/dist/semantics/normalize/producers/cited-value-type.d.ts +2 -2
  140. package/dist/semantics/normalize/producers/cited-value-type.js +2 -2
  141. package/dist/semantics/normalize/producers/class-lifecycle.js +39 -9
  142. package/dist/semantics/normalize/producers/computations.js +36 -5
  143. package/dist/semantics/normalize/producers/conditional-guard.d.ts +6 -0
  144. package/dist/semantics/normalize/producers/conditional-guard.js +5 -0
  145. package/dist/semantics/normalize/producers/control.js +7 -1
  146. package/dist/semantics/normalize/producers/destructuring.js +8 -9
  147. package/dist/semantics/normalize/producers/invocations.js +55 -2
  148. package/dist/semantics/normalize/producers/properties.d.ts +13 -0
  149. package/dist/semantics/normalize/producers/properties.js +21 -3
  150. package/dist/semantics/normalize/producers/references.js +8 -4
  151. package/dist/semantics/normalize/reachability.d.ts +15 -3
  152. package/dist/semantics/normalize/reachability.js +128 -20
  153. package/dist/semantics/normalize/return-bindings.js +3 -3
  154. package/dist/semantics/normalize/source-native-iterable.d.ts +19 -0
  155. package/dist/semantics/normalize/source-native-iterable.js +74 -0
  156. package/dist/semantics/normalize/structural-any-binding-consumer.d.ts +1 -1
  157. package/dist/semantics/normalize/structural-declarations.js +1 -1
  158. package/dist/semantics/normalize/structural-indexed-access.js +9 -0
  159. package/dist/semantics/normalize/structural.js +11 -0
  160. package/dist/semantics/normalize/unshared-array-result.d.ts +42 -0
  161. package/dist/semantics/normalize/unshared-array-result.js +269 -0
  162. package/dist/semantics/package-sources.js +3 -2
  163. package/dist/semantics/program.d.ts +8 -0
  164. package/dist/semantics/program.js +55 -0
  165. package/dist/semantics/source-transform-exports.d.ts +8 -0
  166. package/dist/semantics/source-transform-exports.js +145 -0
  167. package/dist/semantics/source-transform-protocol.d.ts +22 -0
  168. package/dist/semantics/this-constructor-source-transform.js +19 -1
  169. package/dist/targets/cpp/class-layout.d.ts +2 -0
  170. package/dist/targets/cpp/class-layout.js +35 -1
  171. package/dist/targets/cpp/class-properties/emit-class-properties.d.ts +11 -1
  172. package/dist/targets/cpp/class-properties/emit-class-properties.js +33 -4
  173. package/dist/targets/cpp/conversions.js +6 -3
  174. package/dist/targets/cpp/emit-callable.js +73 -7
  175. package/dist/targets/cpp/emit-context.d.ts +23 -9
  176. package/dist/targets/cpp/emit-context.js +19 -8
  177. package/dist/targets/cpp/emit-equality.js +41 -1
  178. package/dist/targets/cpp/emit-exceptions.js +29 -11
  179. package/dist/targets/cpp/emit-iterator-object-view.js +2 -2
  180. package/dist/targets/cpp/emit-iterator.js +33 -9
  181. package/dist/targets/cpp/emit-live-field-view.js +6 -1
  182. package/dist/targets/cpp/emit-narrowing.d.ts +11 -3
  183. package/dist/targets/cpp/emit-narrowing.js +58 -18
  184. package/dist/targets/cpp/emit-native-field-view.d.ts +3 -1
  185. package/dist/targets/cpp/emit-native-field-view.js +84 -8
  186. package/dist/targets/cpp/emit-properties.d.ts +1 -0
  187. package/dist/targets/cpp/emit-properties.js +26 -7
  188. package/dist/targets/cpp/emit-protocol-iterator.js +5 -2
  189. package/dist/targets/cpp/emit-record-view.js +14 -2
  190. package/dist/targets/cpp/emit-tostring.js +23 -1
  191. package/dist/targets/cpp/emit-union-properties.js +1 -1
  192. package/dist/targets/cpp/emit.d.ts +1 -1
  193. package/dist/targets/cpp/emit.js +132 -21
  194. package/dist/targets/cpp/host/emit-host-invoke.js +2 -2
  195. package/dist/targets/cpp/host/emit-host-object.js +28 -2
  196. package/dist/targets/cpp/host/emit-host-properties.js +9 -1
  197. package/dist/targets/cpp/host/emit-host-value.d.ts +1 -1
  198. package/dist/targets/cpp/host/emit-host-value.js +8 -6
  199. package/dist/targets/cpp/host/host-members.js +2 -1
  200. package/dist/targets/cpp/prototype/emit-prototype-array.js +69 -5
  201. package/dist/targets/cpp/prototype/emit-prototype-invoke.js +9 -9
  202. package/dist/targets/cpp/prototype/emit-prototype-iterator.js +2 -2
  203. package/dist/targets/cpp/prototype/emit-prototype-promise.js +7 -7
  204. package/dist/targets/cpp/records.d.ts +1 -0
  205. package/dist/targets/cpp/records.js +16 -7
  206. package/dist/targets/cpp/translation-unit.js +30 -16
  207. package/package.json +8 -7
  208. package/src/targets/cpp/runtime/gea_dynamic_proxy.h +42 -3
  209. package/src/targets/cpp/runtime/gea_eval.h +3 -0
  210. package/src/targets/cpp/runtime/gea_runtime.h +2407 -684
@@ -1595,8 +1595,8 @@ moduleRecords = emptyCommonJsModuleRecordCensus) => {
1595
1595
  return upstream;
1596
1596
  // `Array.isArray(pattern) ? pattern[0] : p` reads the tuple the
1597
1597
  // predicate narrowed to, not the receiver's declared union: resolving
1598
- // the receiver through its declaration loses the narrowing, and hono's
1599
- // trie-router `key` stayed `any` and was boxed into every lookup.
1598
+ // the receiver through its declaration loses the narrowing, and a
1599
+ // trie router's `key` stayed `any` and was boxed into every lookup.
1600
1600
  const predicateNarrowed = arrayPredicateNarrowedElementTypeOf(checker, node);
1601
1601
  if (predicateNarrowed)
1602
1602
  return predicateNarrowed;
@@ -2413,7 +2413,16 @@ hostProvided = noHostProvidedNames) => {
2413
2413
  const contracts = contractsFor(declaration) ?? [];
2414
2414
  const contractTypes = [];
2415
2415
  for (const contract of contracts) {
2416
- const type = callbackContractParameterType(checker, contract, parameterIndex);
2416
+ // An intrinsic Array frame holds only while the method and the indices
2417
+ // it reads are the intrinsic's. The obligation joins the answer being
2418
+ // published: inference asks under `protocolLedger.capture`, and the
2419
+ // seal below re-asks an answer that already carries it.
2420
+ if ('intrinsic' in contract) {
2421
+ if (!protocolLedger)
2422
+ return { refused: 'callback-contract-intrinsic-protocol-unavailable' };
2423
+ protocolLedger.include(contract.requirements);
2424
+ }
2425
+ const type = callbackContractParameterType(checker, contract, parameterIndex, propagatingTypeAt);
2417
2426
  if (!type)
2418
2427
  return { refused: 'callback-contract-has-no-parameter' };
2419
2428
  contractTypes.push(type);
@@ -1,3 +1,4 @@
1
+ import type { SourceNativeIterable } from './source-native-iterable.js';
1
2
  import type { AbsentGlobalCensus } from './absent-globals.js';
2
3
  import type { DeadMethodCopies } from './dead-method-copies.js';
3
4
  import type { ArgumentsObjectCensus } from './arguments-objects.js';
@@ -51,6 +52,7 @@ import type { SourceCallableReadonlySet } from './flow/source-callable-readonly-
51
52
  * them into one.
52
53
  */
53
54
  export interface ProducerContext {
55
+ readonly nativeIterableAt?: (source: ts.Expression, consumer: ts.CallExpression | null) => SourceNativeIterable | null;
54
56
  readonly readonlyCallableSetAt?: (access: ts.PropertyAccessExpression | ts.ElementAccessExpression) => SourceCallableReadonlySet | null;
55
57
  /** Exact source slots after shared Object.assign and prototype obligations are discharged. `describedKeysOf` is the
56
58
  * caller's representation key authority for a source no closed family describes (see `SourceValueSession.ownAssignmentOf`). */
@@ -237,6 +239,9 @@ export interface ProducerContext {
237
239
  readonly absentRequirePackageOf: (specifier: string, containingFile: string) => boolean;
238
240
  /** The Program's canonical source-file object for that resolver's target path. */
239
241
  readonly sourceFileOf: (fileName: string) => ts.SourceFile | null;
242
+ /** Actual project-selected automatic JSX runtime, through the same frontend
243
+ * resolver. Absent/ambiguous per-file overrides carry no provider witness. */
244
+ readonly jsxRuntimeModuleOf?: (containingFile: string) => ts.SourceFile | null;
240
245
  /**
241
246
  * Which ambient globals an installed host declares it does NOT provide.
242
247
  *
@@ -17,6 +17,8 @@ import ts from 'typescript';
17
17
  export const bindingKindOf = (declaration) => {
18
18
  if (ts.isFunctionExpression(declaration) && declaration.name)
19
19
  return { mutable: false, temporalDeadZone: false };
20
+ if (ts.isClassDeclaration(declaration) || (ts.isClassExpression(declaration) && declaration.name))
21
+ return { mutable: ts.isClassDeclaration(declaration), temporalDeadZone: true };
20
22
  const list = ts.isVariableDeclaration(declaration) ? declaration.parent : undefined;
21
23
  if (!list || !ts.isVariableDeclarationList(list))
22
24
  return { mutable: true, temporalDeadZone: false };
@@ -11,8 +11,8 @@ import type { ProducerContext } from '../producer-context.js';
11
11
  * - An `Object.create(null)` call, which publishes the carrier
12
12
  * `objectCreateResultOverride` mints rather than the ambient `any`.
13
13
  *
14
- * A citation that re-asked the checker boxed the value at the citation: hono's
15
- * trie-router `Node` does `this.#children = children || Object.create(null)`;
14
+ * A citation that re-asked the checker boxed the value at the citation: a
15
+ * trie router's `Node` does `this.#children = children || Object.create(null)`;
16
16
  * the merge cited the call as `any` and the field write cited the merge as
17
17
  * `any`, so the optional parameter was boxed and unboxed into the field.
18
18
  */
@@ -12,8 +12,8 @@ import { logicalMergeTypeOf } from './logical-merge-type.js';
12
12
  * - An `Object.create(null)` call, which publishes the carrier
13
13
  * `objectCreateResultOverride` mints rather than the ambient `any`.
14
14
  *
15
- * A citation that re-asked the checker boxed the value at the citation: hono's
16
- * trie-router `Node` does `this.#children = children || Object.create(null)`;
15
+ * A citation that re-asked the checker boxed the value at the citation: a
16
+ * trie router's `Node` does `this.#children = children || Object.create(null)`;
17
17
  * the merge cited the call as `any` and the field write cited the merge as
18
18
  * `any`, so the optional parameter was boxed and unboxed into the field.
19
19
  */
@@ -225,6 +225,7 @@ export const createClassLifecycleProducer = (context) => {
225
225
  ...(allocated === 'class-constructor-object' && ts.isClassLike(node)
226
226
  ? {
227
227
  classDeclaration: context.identities.declarationIdOf(node),
228
+ ...(candidate.classConstructionDeferred ? { classConstructionDeferred: true } : {}),
228
229
  functionName: staticClassNameOf(node),
229
230
  functionLength: staticClassLengthOf(node)
230
231
  }
@@ -361,7 +362,8 @@ export const createClassLifecycleProducer = (context) => {
361
362
  allocates: true,
362
363
  callsUserCode: false
363
364
  }),
364
- ...(candidate.classLayoutOnly ? { classLayoutOnly: true } : {})
365
+ ...(candidate.classLayoutOnly ? { classLayoutOnly: true } : {}),
366
+ ...(candidate.classConstructionDeferred ? { classConstructionDeferred: true } : {})
365
367
  };
366
368
  operations.push(bindOperation);
367
369
  if (heritageOperation)
@@ -407,7 +409,7 @@ export const createClassLifecycleProducer = (context) => {
407
409
  edges.push({ kind: 'value', result: classValue.id, to: nameId, role: 'initializer', ordinal: 0 });
408
410
  }
409
411
  const written = writtenConstructorOf(node);
410
- const writtenConstructor = candidate.classLayoutOnly ? null : writtenConstructorAllocationOf(candidate, node);
412
+ const writtenConstructor = candidate.classLayoutOnly || candidate.classConstructionDeferred ? null : writtenConstructorAllocationOf(candidate, node);
411
413
  if (writtenConstructor)
412
414
  operations.push(writtenConstructor);
413
415
  // A parameter property is two declarations written as one:
@@ -779,7 +781,10 @@ export const createClassLifecycleProducer = (context) => {
779
781
  (ts.isArrowFunction(node.initializer) || ts.isFunctionExpression(node.initializer)) &&
780
782
  context.specializations.isGeneric(node.initializer) &&
781
783
  context.specializations.specializationsOf(context.identities.genericSubjectOf(node.initializer)).length === 0;
782
- if (node.initializer && !candidate.classLayoutOnly && !uninstantiatedGenericInitializer) {
784
+ if (node.initializer &&
785
+ !candidate.classLayoutOnly &&
786
+ (isStatic || !candidate.classConstructionDeferred) &&
787
+ !uninstantiatedGenericInitializer) {
783
788
  // An instance field initializer runs with the new instance as `this`;
784
789
  // a static field initializer runs during class evaluation with the
785
790
  // constructor object as `this`. These are different physical carriers,
@@ -880,15 +885,40 @@ export const createClassLifecycleProducer = (context) => {
880
885
  const source = candidate.id;
881
886
  const declaration = context.identities.declarationIdOf(node);
882
887
  const classId = context.identities.declarationIdOf(classNode);
888
+ // Like a static field initializer, a block is invoked once with this
889
+ // exact evaluated class value. Giving its body a real receiver ABI also
890
+ // keeps each factory evaluation's constructor identity intact.
891
+ const receiver = context.types.valueTypeAt(classNode);
892
+ const shape = context.table.intern({
893
+ kind: 'signature',
894
+ call: [{ parameters: [], minimumArity: 0, thisParameter: receiver, implicitReceiver: true, result: voidType }],
895
+ construct: []
896
+ });
897
+ const allocationId = mintOperationId(context.ordinals, source, 'allocation');
898
+ const allocation = {
899
+ id: allocationId,
900
+ family: 'allocation',
901
+ allocated: 'function-object',
902
+ shape,
903
+ callable: context.identities.functionIdOf(node),
904
+ caller: candidate.caller,
905
+ operands: [],
906
+ results: [mintResult(allocationId, 'value', shape)],
907
+ completion: normalCompletion,
908
+ effects: { ...pureEffects, allocates: true },
909
+ evaluationOrdinal: candidate.evaluationOrdinal
910
+ };
911
+ const initializer = resultOf(allocation, 'value');
883
912
  const id = mintOperationId(context.ordinals, source, 'class-lifecycle');
884
- const operation = buildOperation(id, candidate.caller, context.evaluationOrdinals.next(candidate.caller), 'run-static-block', declaration, classId, null, null, [],
913
+ const operation = buildOperation(id, candidate.caller, context.evaluationOrdinals.next(candidate.caller), 'run-static-block', declaration, classId, null, null, [operand('initializer', 0, { kind: 'result', result: initializer.id }, shape)],
885
914
  // The block body can throw and can read/write arbitrary state; its own
886
- // statements are separately normalized under the `static-block` region
887
- // census already creates, so this operation is the block's entry point.
915
+ // statements are normalized under this callable's owner.
888
916
  throwingCompletion, { readsMutableState: true, writesMutableState: true, allocates: false, callsUserCode: true });
889
- const edges = [];
890
- edges.push({ kind: 'evaluation', from: ready, to: operation.id });
891
- return { kind: 'operations', operations: [operation], edges };
917
+ const edges = [
918
+ { kind: 'evaluation', from: ready, to: operation.id },
919
+ { kind: 'value', result: initializer.id, to: operation.id, role: 'initializer', ordinal: 0 }
920
+ ];
921
+ return { kind: 'operations', operations: [allocation, operation], edges };
892
922
  };
893
923
  /**
894
924
  * A class expression's `evaluate-heritage` event -- the one lifecycle step
@@ -8,6 +8,7 @@ import { isAssignmentOperatorKind, logicalAssignmentOperators, sourceForValue, s
8
8
  import { normalCompletion, pureEffects, throwingCompletion } from '../../model/operands.js';
9
9
  import { propertyExpressionValueTypeAt } from './properties.js';
10
10
  import { citedValueTypeAt } from './cited-value-type.js';
11
+ import { constantConditionalGuardId, constantConditionalGuardResult } from './conditional-guard.js';
11
12
  import { ordinaryObjectDataWriteIsAbsent } from '../callable-data-write.js';
12
13
  const tokenText = (kind) => ts.tokenToString(kind) ?? ts.SyntaxKind[kind];
13
14
  /**
@@ -137,8 +138,8 @@ const finishComputation = (context, candidate, node, form, operatorText, operand
137
138
  // checker subtype-reduces `cond ? xs.map(f) : []` to the populated arm
138
139
  // for the same reason, and `structural.ts` drops the identical arm from
139
140
  // a checker union. Kept as a second arm, the merge was a tagged union of
140
- // two arrays the binding had to select from (hono's RegExpRouter
141
- // `ownRoute`), where `mergeIncoming` builds the empty literal directly
141
+ // two arrays the binding had to select from (a regular-expression
142
+ // router's `ownRoute`), where `mergeIncoming` builds the empty literal directly
142
143
  // in the populated arm's carrier.
143
144
  const shapeOf = (id) => (context.table.isOpen(id) ? undefined : context.table.get(id).shape);
144
145
  const elementless = (id) => {
@@ -333,11 +334,34 @@ const contributeLogicalAssignment = (context, candidate, node, kind) => {
333
334
  };
334
335
  };
335
336
  const contributeConditional = (context, candidate, node) => {
336
- const conditionSource = sourceForValue(context, node.condition);
337
+ const rawCondition = sourceForValue(context, node.condition);
338
+ let conditionSource = rawCondition;
339
+ let materialized = null;
340
+ if (rawCondition.kind === 'constant') {
341
+ // A literal is normally an inline operand. A lazy branch additionally
342
+ // needs a citable result so the generic subtree-gating pass can place all
343
+ // branch effects under the same guard. This single-value comma preserves
344
+ // the literal's type/value without coercion or an invented runtime call.
345
+ const id = constantConditionalGuardId(node.condition, context);
346
+ const type = context.types.typeAt(node.condition);
347
+ materialized = {
348
+ id,
349
+ family: 'computation',
350
+ form: 'comma',
351
+ operator: ',',
352
+ caller: candidate.caller,
353
+ evaluationOrdinal: candidate.evaluationOrdinal,
354
+ operands: [operand('value', 0, rawCondition, type)],
355
+ results: [mintResult(id, 'value', type)],
356
+ completion: normalCompletion,
357
+ effects: pureEffects
358
+ };
359
+ conditionSource = { kind: 'result', result: constantConditionalGuardResult(node.condition, context) };
360
+ }
337
361
  if (conditionSource.kind !== 'result') {
338
362
  return {
339
363
  kind: 'blocked',
340
- blocker: blocked(candidate.id, 'computation', 'a conditional expression needs a producible condition result to gate its branches; a constant, this, or super condition is not modelled', 'P0')
364
+ blocker: blocked(candidate.id, 'computation', 'a conditional expression needs a producible condition result; this or super is not modelled', 'P0')
341
365
  };
342
366
  }
343
367
  const condition = operand('condition', 0, conditionSource, context.types.typeAt(node.condition));
@@ -354,7 +378,14 @@ const contributeConditional = (context, candidate, node) => {
354
378
  guard: conditionSource.result,
355
379
  takenWhen: 'falsy'
356
380
  });
357
- return finishComputation(context, candidate, node, 'conditional', '?:', [condition, consequent, alternate], normalCompletion, pureEffects);
381
+ const contribution = finishComputation(context, candidate, node, 'conditional', '?:', [condition, consequent, alternate], normalCompletion, pureEffects);
382
+ if (!materialized || contribution.kind !== 'operations')
383
+ return contribution;
384
+ return {
385
+ ...contribution,
386
+ operations: [materialized, ...contribution.operations],
387
+ edges: [...valueEdgesInto(materialized.id, materialized.operands), ...contribution.edges]
388
+ };
358
389
  };
359
390
  const contributeTemplate = (context, candidate, node) => {
360
391
  // The literal text between the substitutions is part of the value, so it is
@@ -0,0 +1,6 @@
1
+ import type ts from 'typescript';
2
+ import type { CitationFacts } from './references.js';
3
+ /** A literal condition has no ordinary operation. The conditional producer
4
+ * publishes this value coordinate; subtree gating cites exactly that result. */
5
+ export declare const constantConditionalGuardId: (condition: ts.Expression, facts: CitationFacts) => import("../../../identity/ids.js").OperationId;
6
+ export declare const constantConditionalGuardResult: (condition: ts.Expression, facts: CitationFacts) => import("../../../identity/ids.js").SemanticResultId;
@@ -0,0 +1,5 @@
1
+ import { operationId, semanticResultId } from '../../../identity/ids.js';
2
+ /** A literal condition has no ordinary operation. The conditional producer
3
+ * publishes this value coordinate; subtree gating cites exactly that result. */
4
+ export const constantConditionalGuardId = (condition, facts) => operationId(facts.identities.nodeIdOf(condition), 'computation', 0);
5
+ export const constantConditionalGuardResult = (condition, facts) => semanticResultId(constantConditionalGuardId(condition, facts), 'value');
@@ -5,6 +5,7 @@ import { familyOf, isFieldInitializerBody } from '../census.js';
5
5
  import { blocked, mintOperationId, mintResult, operand } from './mint.js';
6
6
  import { contributePlainLoop, contributeTailTestedLoop } from './control-loops.js';
7
7
  import { resolveExpressionOperand } from './boundary.js';
8
+ import { unsharedReturnedArray } from '../unshared-array-result.js';
8
9
  import { unwrapErasedExpression } from './erasure.js';
9
10
  import { isDynamicIterationSource, mintIteratorSteps } from './protocol.js';
10
11
  import { hasNativeEnumerationCursor, hasNativeIterationCursor, isGeneratorType, presentIterationArm, nativeCollectionIterationViewOf, valueEdgesInto } from './shared.js';
@@ -468,7 +469,12 @@ const contributeReturn = (context, candidate, node) => {
468
469
  const resolved = resolveExpressionOperand(context, node.expression);
469
470
  if (!resolved)
470
471
  return blockedContribution(candidate, 'no normalized operation identifies the returned value');
471
- valueOperand = { ...operand('value', 0, resolved.source, resolved.type), ...(resolved.asserted ? { asserted: true } : {}) };
472
+ valueOperand = {
473
+ ...operand('value', 0, resolved.source, resolved.type),
474
+ ...(resolved.asserted ? { asserted: true } : {}),
475
+ // A `finally` runs after the value is taken and may still fill the local.
476
+ ...(!nearestInterceptingFinally(node) && unsharedReturnedArray(context.checker, node) ? { unsharedFreshArray: true } : {})
477
+ };
472
478
  }
473
479
  else {
474
480
  const undefinedType = context.table.intern({ kind: 'primitive', primitive: 'undefined' });
@@ -7,6 +7,7 @@ import { normalCompletion, throwingCompletion } from '../../model/operands.js';
7
7
  import { mintOperationId, mintResult, operand } from './mint.js';
8
8
  import { asBlocked, hasNativeIterationCursor, isFixedArityTupleType, isGeneratorType, isStrictContext, resultEdge, unwrapErased, valueEdgesInto } from './shared.js';
9
9
  import { citeExpressionResult } from './references.js';
10
+ import { keyOf } from './properties.js';
10
11
  import { memberTypeOf } from '../derived-expression-type.js';
11
12
  import { bindingKindOf } from './binding-kind.js';
12
13
  import { iteratorYieldStructuralType, iteratorYieldTypesOf } from './iteration-yield.js';
@@ -1135,13 +1136,11 @@ export const createDestructuringProducer = (context) => {
1135
1136
  const receiver = citeExpressionResult(access.expression, context);
1136
1137
  if (receiver.kind === 'unmodelled')
1137
1138
  return refuse(receiver.reason);
1138
- const targetKey = ts.isPropertyAccessExpression(access)
1139
- ? access.name.text
1140
- : ts.isStringLiteralLike(access.argumentExpression) || ts.isNumericLiteral(access.argumentExpression)
1141
- ? access.argumentExpression.text
1142
- : null;
1143
- if (targetKey === null)
1144
- return refuse('computed array assignment target keys are not yet modelled');
1139
+ // Destructuring stores use the same typed property-key authority as
1140
+ // ordinary indexed stores; the cited key remains a real SSA operand.
1141
+ const key = keyOf(access, context);
1142
+ if (key.kind === 'blocked')
1143
+ return refuse(key.reason);
1145
1144
  const id = mintOperationId(context.ordinals, candidate.id, 'property');
1146
1145
  const receiverType = context.types.typeAt(access.expression);
1147
1146
  write = {
@@ -1149,13 +1148,13 @@ export const createDestructuringProducer = (context) => {
1149
1148
  family: 'property',
1150
1149
  internalMethod: 'set',
1151
1150
  strict: isStrictContext(access, context.buildIsStrict),
1152
- keyIsComputed: false,
1151
+ keyIsComputed: key.computed,
1153
1152
  descriptor: null,
1154
1153
  caller: candidate.caller,
1155
1154
  evaluationOrdinal: candidate.evaluationOrdinal,
1156
1155
  operands: [
1157
1156
  operand('receiver', 0, receiver.source, receiverType, { kind: 'provenance' }),
1158
- operand('key', 0, { kind: 'constant', text: targetKey, literal: 'string' }, stringType),
1157
+ operand('key', 0, key.source, key.type),
1159
1158
  operand('value', 0, value, boundType)
1160
1159
  ],
1161
1160
  results: [mintResult(id, 'value', receiverType)],
@@ -14,7 +14,7 @@ import { isFabricatedSignatureShape, structuralCallSignatures } from '../structu
14
14
  import { contextualArrayConstructTypeAt, contextualCollectionTypeAt, statedCollectionTypeAt } from '../structural-array-element.js';
15
15
  import { implementationSignatureOf } from '../structural-declarations.js';
16
16
  import { physicalGeneratorOverloadResultAt, physicalInheritedCallableReturnAt } from '../physical-overload-result.js';
17
- import { unsharedArrayResultBodyOf } from '../unshared-array-result.js';
17
+ import { readOnlyArrayArgumentAt, unsharedArrayResultBodyOf } from '../unshared-array-result.js';
18
18
  import { regionId, semanticResultId, withoutSpecialization } from '../../../identity/ids.js';
19
19
  import { bindingKindOf } from './binding-kind.js';
20
20
  import { declaresExactArms } from './exact-arms.js';
@@ -505,6 +505,33 @@ const exactFunctionTarget = (context, node, signature) => {
505
505
  ]
506
506
  };
507
507
  };
508
+ /**
509
+ * The body a call runs and the formal an argument binds, by the same exact
510
+ * target proof `buildTarget` publishes: a never-reassigned binding that holds
511
+ * exactly one source function. Positions after a spread are not known.
512
+ */
513
+ const argumentFormalOf = (context) => (call, argument) => {
514
+ const index = call.arguments.indexOf(argument);
515
+ if (index < 0 || call.arguments.slice(0, index + 1).some(ts.isSpreadElement))
516
+ return null;
517
+ const signature = context.checker.getResolvedSignature(call);
518
+ if (!signature || exactFunctionTarget(context, call, signature) === null)
519
+ return null;
520
+ const declaration = sourceImplementationSignatureOf(context, signature, 'generic-too')?.declaration ?? signature.declaration;
521
+ return declaration && isFunctionLikeSourceDeclaration(declaration) ? { callee: declaration, index } : null;
522
+ };
523
+ /** See `SemanticOperand.readOnlyArrayArgument`: an argument the call may take as an element-wise copy. */
524
+ const readOnlyArrayArgumentsOf = (context, node, args, operands) => {
525
+ if (!ts.isCallExpression(node) || args.some(ts.isSpreadElement))
526
+ return operands;
527
+ const formalOf = argumentFormalOf(context);
528
+ return operands.map((entry) => {
529
+ const argument = entry.role === 'argument' ? args[entry.ordinal] : undefined;
530
+ return argument !== undefined && readOnlyArrayArgumentAt(context.checker, argument, formalOf)
531
+ ? { ...entry, readOnlyArrayArgument: true }
532
+ : entry;
533
+ });
534
+ };
508
535
  /** See `InvocationOperation.unsharedArrayResult`; asked only of a call whose own result is an Array. */
509
536
  const unsharedArrayResultFactOf = (context, node) => {
510
537
  if (!ts.isCallExpression(node))
@@ -547,6 +574,31 @@ const freshIntrinsicArrayResultFactOf = (context, node) => {
547
574
  });
548
575
  return lib ? { freshIntrinsicArrayResult: true } : {};
549
576
  };
577
+ /**
578
+ * `Array.from(...)` / `Array.of(...)`: the standard library's own static
579
+ * factories, which answer an array they just created (ECMA-262 ArrayCreate on
580
+ * the intrinsic `%Array%` receiver) and hold no reference to it. Only while
581
+ * neither the `Array` binding nor the member was replaced
582
+ * (`intrinsicStaticMemberIsIntact`). See `InvocationOperation.freshIntrinsicArrayFactory`.
583
+ */
584
+ const freshIntrinsicArrayFactoryFactOf = (context, node) => {
585
+ if (!ts.isCallExpression(node) || ts.isOptionalChain(node))
586
+ return {};
587
+ const callee = node.expression;
588
+ if (!ts.isPropertyAccessExpression(callee) || !ts.isIdentifier(callee.name) || !ts.isIdentifier(callee.expression))
589
+ return {};
590
+ if (callee.expression.text !== 'Array' || (callee.name.text !== 'from' && callee.name.text !== 'of'))
591
+ return {};
592
+ if (!context.checker.isArrayType(context.checker.getTypeAtLocation(node)))
593
+ return {};
594
+ const member = context.checker.getSymbolAtLocation(callee.name);
595
+ const owner = context.checker.getSymbolAtLocation(callee.expression);
596
+ const statics = (member?.declarations ?? []).every((declaration) => {
597
+ const parent = declaration.parent;
598
+ return ts.isInterfaceDeclaration(parent) && parent.name.text === 'ArrayConstructor';
599
+ });
600
+ return statics && intrinsicStaticMemberIsIntact(context, owner, member, callee) ? { freshIntrinsicArrayFactory: true } : {};
601
+ };
550
602
  const implicitSourceConstructorTarget = (context, node) => {
551
603
  // HOLDS: what `new`'s own callee expression refers to, read the
552
604
  // census-aware way (`context.types.rawTypeAt`) rather than the bare
@@ -1841,7 +1893,7 @@ export const createInvocationProducer = (context) => ({
1841
1893
  }
1842
1894
  const expansions = argumentList.operations;
1843
1895
  const expansionEdges = argumentList.edges;
1844
- operands.push(...argumentList.operands);
1896
+ operands.push(...readOnlyArrayArgumentsOf(context, node, args, argumentList.operands));
1845
1897
  // This call's own published result stays the checker's real, un-awaited
1846
1898
  // type -- an un-awaited async call yields a genuine `Promise<T>` value
1847
1899
  // now that `promise` is a real carrier
@@ -2144,6 +2196,7 @@ export const createInvocationProducer = (context) => ({
2144
2196
  : {}),
2145
2197
  ...unsharedArrayResultFactOf(context, node),
2146
2198
  ...freshIntrinsicArrayResultFactOf(context, node),
2199
+ ...freshIntrinsicArrayFactoryFactOf(context, node),
2147
2200
  ...deadEventCallFactOf(context, node),
2148
2201
  ...(intrinsicPropertyCall === 'get' ||
2149
2202
  intrinsicPropertyCall === 'set' ||
@@ -1,8 +1,21 @@
1
1
  import ts from 'typescript';
2
2
  import { type StructuralTypeId } from '../../../identity/ids.js';
3
+ import type { PrimitiveFamily } from '../../model/coverage.js';
4
+ import { type OperandSource } from '../../model/operands.js';
3
5
  import type { FamilyProducer } from '../contribution.js';
4
6
  import type { ProducerContext } from '../producer-context.js';
5
7
  type AccessNode = ts.PropertyAccessExpression | ts.ElementAccessExpression;
8
+ type KeyResolution = {
9
+ readonly kind: 'key';
10
+ readonly computed: boolean;
11
+ readonly source: OperandSource;
12
+ readonly type: StructuralTypeId;
13
+ } | {
14
+ readonly kind: 'blocked';
15
+ readonly reason: string;
16
+ readonly missingPrimitive: PrimitiveFamily | null;
17
+ };
18
+ export declare const keyOf: (node: AccessNode, context: ProducerContext) => KeyResolution;
6
19
  /**
7
20
  * The value type published for this exact property expression.
8
21
  *
@@ -16,6 +16,7 @@ import { assertsType, enclosingCallIfCallee, outermostErasureOf, unwrapErasedExp
16
16
  import { isScriptGlobalObjectPropertyDeclaration } from '../script-global-redefinition.js';
17
17
  import { primitivePropertyIsAbsent } from '../primitive-property-absence.js';
18
18
  import { nativeOwnSlotOf } from './native-own-assignment.js';
19
+ import { isUnsharedFreshTableStore } from '../fresh-table-last-use.js';
19
20
  import { nativeCallableReadonlySetSourceOf } from './native-callable-readonly-set.js';
20
21
  import { assertedReceiverArmMayLackMember } from '../asserted-arm-absence.js';
21
22
  import { keySetTouches } from '../host-mutation-keys.js';
@@ -88,7 +89,7 @@ const intentOf = (node) => {
88
89
  }
89
90
  return { kind: 'get' };
90
91
  };
91
- const keyOf = (node, context) => {
92
+ export const keyOf = (node, context) => {
92
93
  // A static key is a String, whatever the property it names holds. Asking the
93
94
  // checker for the type at the name node answers a different question -- it
94
95
  // gives the *property's* type -- and taking that answer spells the key with
@@ -636,7 +637,12 @@ const observablyAbsentElementTypeOf = (context, node, valueType) => {
636
637
  members: [valueType, context.table.intern({ kind: 'primitive', primitive: 'undefined' })]
637
638
  });
638
639
  }
639
- if (!ts.isElementAccessExpression(node) || !testsItsOperand(node))
640
+ // An equality test against `undefined` consumes nothing either: three's
641
+ // `if ( renderTargetProperties.__webglDepthbuffer[ i ] === undefined )`
642
+ // reads an array it fills in that very branch, so the read is out of range
643
+ // on its first pass, and the bare element carrier aborted the program at
644
+ // the comparison meant to observe that absence.
645
+ if (!ts.isElementAccessExpression(node) || !(testsItsOperand(node) || comparesWithUndefined(context, node)))
640
646
  return valueType;
641
647
  // Each constituent, because a union of array types indexes the same way:
642
648
  // a parameter declared `middleware: [[Function, unknown], unknown][] |
@@ -818,6 +824,12 @@ const buildOperations = (candidate, node, intent, key, receiverSource, context,
818
824
  return sourceForValue(context, parent.right);
819
825
  return { kind: 'result', result: semanticResultId(operationId(context.identities.nodeIdOf(parent), 'computation', 0), 'value') };
820
826
  };
827
+ // See `SemanticOperand.unsharedFreshTable`: only a plain `=` whose
828
+ // right-hand side is the local itself.
829
+ const unsharedFreshTableStore = () => {
830
+ const parent = outermostErasureOf(node).parent;
831
+ return (ts.isBinaryExpression(parent) && parent.left === outermostErasureOf(node) && isUnsharedFreshTableStore(context.checker, parent.right));
832
+ };
821
833
  const makeOperation = (internalMethod, receiverEvaluation, keyEvaluation, effects) => {
822
834
  const id = mintOperationId(context.ordinals, candidate.id, 'property');
823
835
  const stored = internalMethod === 'set' ? storedValue() : null;
@@ -931,7 +943,13 @@ const buildOperations = (candidate, node, intent, key, receiverSource, context,
931
943
  ? { ...operand('receiver', 0, receiverSource, receiverType, receiverEvaluation), asserted: true }
932
944
  : operand('receiver', 0, receiverSource, receiverType, receiverEvaluation),
933
945
  operand('key', 0, key.source, key.type, keyEvaluation),
934
- ...(stored ? [operand('value', 0, stored, valueType)] : []),
946
+ ...(stored
947
+ ? [
948
+ unsharedFreshTableStore()
949
+ ? { ...operand('value', 0, stored, valueType), unsharedFreshTable: true }
950
+ : operand('value', 0, stored, valueType)
951
+ ]
952
+ : []),
935
953
  ...(guardSource && guardExpression
936
954
  ? [operand('short-circuit-guard', 0, guardSource, context.types.typeAt(guardExpression), { kind: 'provenance' })]
937
955
  : [])
@@ -5,7 +5,7 @@ import { enclosingCallIfCallee, flowNarrowsType, unwrapErasedExpression } from '
5
5
  import { publishesShortCircuit } from './optional-chain.js';
6
6
  import { operationId, regionId, semanticResultId } from '../../../identity/ids.js';
7
7
  import { normalCompletion, pureEffects, throwingCompletion } from '../../model/operands.js';
8
- import { familyOf } from '../census.js';
8
+ import { familyOf, isClassElementNameEvaluation } from '../census.js';
9
9
  import { bindingKindOf } from './binding-kind.js';
10
10
  import { blocked, mintOperationId, mintResult, operand } from './mint.js';
11
11
  import { valueSymbolAt } from '../unresolvable-names.js';
@@ -765,6 +765,8 @@ const thisCanThrow = (node) => {
765
765
  */
766
766
  const nearestOwningScopeIsArrow = (node) => {
767
767
  for (let current = node.parent; current; current = current.parent) {
768
+ if (isClassElementNameEvaluation(node, current))
769
+ continue;
768
770
  if (ts.isArrowFunction(current))
769
771
  return true;
770
772
  if (ts.isFunctionDeclaration(current) ||
@@ -780,9 +782,11 @@ const nearestOwningScopeIsArrow = (node) => {
780
782
  }
781
783
  return false;
782
784
  };
783
- /** The class whose constructor object a static `this` denotes, plus whether the nearest owner is a non-callable static block. */
785
+ /** The class whose constructor object a static `this` denotes, plus whether the nearest source owner is a static block. */
784
786
  const staticThisOwner = (node) => {
785
787
  for (let current = node.parent; current; current = current.parent) {
788
+ if (isClassElementNameEvaluation(node, current))
789
+ continue;
786
790
  if (ts.isArrowFunction(current))
787
791
  continue;
788
792
  if (ts.isClassStaticBlockDeclaration(current)) {
@@ -795,7 +799,7 @@ const staticThisOwner = (node) => {
795
799
  const isStatic = (ts.getCombinedModifierFlags(current) & ts.ModifierFlags.Static) !== 0;
796
800
  return isStatic && ts.isClassLike(current.parent) ? { classNode: current.parent, block: false } : null;
797
801
  }
798
- if (ts.isFunctionLike(current) || ts.isClassLike(current))
802
+ if (ts.isFunctionLike(current))
799
803
  return null;
800
804
  }
801
805
  return null;
@@ -865,7 +869,7 @@ const buildThisReference = (candidate, node, context) => {
865
869
  // evaluates it, and an operand that claimed to would order an evaluation
866
870
  // the language does not perform.
867
871
  operands: [
868
- operand(staticOwner?.block ? 'static-class-receiver' : captured ? 'captured-receiver' : 'receiver', 0, { kind: 'receiver' }, type, {
872
+ operand(captured ? 'captured-receiver' : staticOwner?.block ? 'static-class-receiver' : 'receiver', 0, { kind: 'receiver' }, type, {
869
873
  kind: 'provenance'
870
874
  })
871
875
  ],
@@ -65,9 +65,11 @@ import ts from 'typescript';
65
65
  *
66
66
  * ## The second granularity: a class member
67
67
  *
68
- * A live class is live whole as a DEFINITION -- its layout, its fields, its
69
- * constructor -- but a method body runs only when a dispatch names it, and a
70
- * dispatch has to name it. `C.m` resolves to one declaration, so a static
68
+ * A live class retains its definition effects and layout. Constructor bodies
69
+ * and instance initializers run only for construction-live classes; unknown
70
+ * construction and escaped/exported constructor values retain them conservatively.
71
+ * A method body runs only when a dispatch names it, and a dispatch has to name
72
+ * it. `C.m` resolves to one declaration, so a static
71
73
  * member is opened by symbol. An instance member cannot be: a structurally
72
74
  * typed parameter, a base-class reference and an interface-typed call all land
73
75
  * on a member the receiver's static type does not identify, and an override is
@@ -131,6 +133,7 @@ export interface ProgramReachability {
131
133
  */
132
134
  readonly memberIsPruned: (node: ts.Node) => boolean;
133
135
  readonly classIsLayoutOnly: (node: ts.ClassDeclaration) => boolean;
136
+ readonly classConstructionIsReachable?: (node: ts.ClassDeclaration) => boolean;
134
137
  }
135
138
  /**
136
139
  * Every statement of every file: the answer when nothing may be pruned.
@@ -189,6 +192,15 @@ export interface ReachabilityInput {
189
192
  * `import {} from 'x'` and does. `typeOnlyModuleUse` is the one answer.
190
193
  */
191
194
  readonly verbatimModuleSyntax?: boolean;
195
+ /** Canonical runtime export binding; only proven absence may drop an export. */
196
+ readonly runtimeExportOf?: (file: ts.SourceFile, name: string) => {
197
+ readonly kind: 'binding';
198
+ readonly symbol: ts.Symbol;
199
+ } | {
200
+ readonly kind: 'missing' | 'refused';
201
+ };
202
+ /** Closed source construction selections; null retains conservative type-compatible alternatives. */
203
+ readonly constructorTargetsOf?: (expression: ts.Expression) => readonly ts.ClassDeclaration[] | null;
192
204
  }
193
205
  /**
194
206
  * Whether the statements this program REACHES in `file` evaluate anything.