hclang 0.37.3 → 0.38.1

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.
@@ -0,0 +1,91 @@
1
+ /**
2
+ * The Demi class, loaded from HC for the fourth hash.
3
+ *
4
+ * `.####` answers a Demi, and a Demi is an HC class, `Demi` in `hc/demi.hc`,
5
+ * not a native one (occurrence/figure 011.20). The frames package derives the
6
+ * phase and loads natively but cannot run HC, so this module installs the
7
+ * constructor it calls (`installDemiConstructor`).
8
+ *
9
+ * The class is read from the compiled-in bundle, not through a resource root,
10
+ * so `.####` works in a bare `evaluate`, which has no root and imports nothing.
11
+ * The file is evaluated the first time a Demi is constructed, once per
12
+ * process, the way an import evaluates a testdoc: its example lines are
13
+ * dropped and the first failure fails the whole. It runs in a namespace of its
14
+ * own, with no host bindings and no root, so it can read nothing but the
15
+ * global operators, and nothing a program declares can reach it. Its outcome
16
+ * is kept, failure included, so it is never evaluated twice. A Demi requested
17
+ * while the file is still loading is `$!.demi-prologue-reentrant`, because
18
+ * the class cannot be defined by itself.
19
+ *
20
+ * What stays native is only what HC cannot say: reading `#`, `##` and `###`
21
+ * in a fixed order with their absence and error rules, and checking that the
22
+ * loads are whole. Everything a Demi does is in the HC source.
23
+ *
24
+ * @module
25
+ */
26
+ import { EvaluationScope, Frame, FrameArray, FrameExpr, installDemiConstructor, } from "../frames.js";
27
+ import { HC_SOURCES } from "../bundle/hc-sources.js";
28
+ import { evaluateSourceText } from "./resource-import.js";
29
+ /** The bundled file that defines the class. */
30
+ export const DEMI_SOURCE = "hc/demi.hc";
31
+ /** The name the file declares the constructor under. */
32
+ export const DEMI_CLASS = "Demi";
33
+ let loaded;
34
+ let loading = false;
35
+ /**
36
+ * Evaluates class source in a namespace of its own, with no host bindings and
37
+ * no root, answering its `Demi` or the failure. Uncached: `demiClass` keeps
38
+ * the one result the process uses.
39
+ *
40
+ * @param source The source text, or undefined when the bundle lacks it.
41
+ * @returns The constructor, or an error.
42
+ */
43
+ export function loadDemiClass(source) {
44
+ if (source === undefined) {
45
+ return Frame.error(`$!.demi-prologue-missing ${DEMI_SOURCE}`);
46
+ }
47
+ const namespace = new FrameArray([]);
48
+ const result = evaluateSourceText(source, EvaluationScope.root(namespace));
49
+ if (result.isFailedResult() || result.observationError())
50
+ return result;
51
+ const constructor = namespace.getOwn(DEMI_CLASS);
52
+ return constructor.is.missing
53
+ ? Frame.error(`$!.demi-prologue-missing ${DEMI_CLASS}`)
54
+ : constructor;
55
+ }
56
+ /**
57
+ * The `Demi` constructor closure, evaluated from the bundle on first use.
58
+ *
59
+ * @returns The constructor, or the error that loading it answered.
60
+ */
61
+ export function demiClass() {
62
+ if (loaded)
63
+ return loaded;
64
+ if (loading)
65
+ return Frame.error("$!.demi-prologue-reentrant");
66
+ loading = true;
67
+ try {
68
+ loaded = loadDemiClass(HC_SOURCES.get(DEMI_SOURCE));
69
+ }
70
+ finally {
71
+ loading = false;
72
+ }
73
+ return loaded;
74
+ }
75
+ /**
76
+ * Constructs a Demi with the HC class: `Demi [phase, left, right]`.
77
+ *
78
+ * @param phase 2 when even, 1 when odd.
79
+ * @param left The left load.
80
+ * @param right The right load.
81
+ * @returns The new instance, or the class's failure.
82
+ */
83
+ export function constructDemi(phase, left, right) {
84
+ const constructor = demiClass();
85
+ if (constructor.isFailedResult() || constructor.observationError()) {
86
+ return constructor;
87
+ }
88
+ const state = new FrameArray([phase, left, right]);
89
+ return FrameExpr.answeredValue(constructor.call(state)).referent();
90
+ }
91
+ installDemiConstructor(constructDemi);
@@ -1,4 +1,6 @@
1
1
  import { Frame, FrameCount, FrameString, FrameSymbol, } from "../frames.js";
2
+ // Installs the Demi class that `.####` constructs (011.20).
3
+ import "./demi-prologue.js";
2
4
  import { EvalPipe, makeSourcePipe } from "./eval-pipe.js";
3
5
  import { evaluateResourceSource } from "./resource-import.js";
4
6
  import { sigilizer } from "./sigilizer.js";
@@ -1,4 +1,4 @@
1
- import { Frame, FrameExpr, FrameGroup, FrameLazy, FrameResource, FrameSymbol, hasCharacterContent, } from "../frames.js";
1
+ import { Frame, FrameExpr, FrameGroup, FrameLazy, FrameResource, FrameString, FrameSymbol, hasCharacterContent, } from "../frames.js";
2
2
  import { EvalPipe, makeSourcePipe } from "./eval-pipe.js";
3
3
  import { LexPipe } from "./lex-pipe.js";
4
4
  import { ParsePipe } from "./parse-pipe.js";
@@ -120,6 +120,22 @@ function evaluateResourceSourceWithChain(resource, scope, activeImports) {
120
120
  ...activeImports,
121
121
  { hostNamespace: scope.hostNamespace, resource: spelling },
122
122
  ];
123
+ return evaluateElements(resource.elements(), scope, nextActiveImports);
124
+ }
125
+ /**
126
+ * Evaluates HC source text as an import would: example lines dropped, the first
127
+ * failed form failing the whole, and the last answer returned. Declarations
128
+ * land in the scope's write target. Used for source the program carries rather
129
+ * than reads, such as the Demi class (`demi-prologue.ts`).
130
+ *
131
+ * @param source The source text.
132
+ * @param scope The scope it evaluates in.
133
+ * @returns The last answer, or the first failure.
134
+ */
135
+ export function evaluateSourceText(source, scope) {
136
+ return evaluateElements([new FrameString(source)], scope, []);
137
+ }
138
+ function evaluateElements(elements, scope, nextActiveImports) {
123
139
  const progress = new ImportProgress();
124
140
  const lexer = makeSourcePipe(EvalPipe.scoped(progress, scope), {
125
141
  importSource: (nestedResource, nestedScope) => evaluateResourceSourceWithChain(nestedResource, nestedScope, nextActiveImports),
@@ -134,7 +150,6 @@ function evaluateResourceSourceWithChain(resource, scope, activeImports) {
134
150
  return progress.firstFailure;
135
151
  };
136
152
  const examples = new ExampleFilter();
137
- const elements = resource.elements();
138
153
  for (const element of elements) {
139
154
  if (element.isFailedResult())
140
155
  return element;
@@ -103,7 +103,10 @@ export class BoundMethod extends Frame {
103
103
  // the lookup order, and a shared body's captured scope is whichever instance
104
104
  // was built last, so a method would read another instance's fields.
105
105
  const result = this.method.call(argument, Frame.nil, state);
106
- if (result.isFailedResult())
106
+ // A mutating method answers its receiver, unless it answered an error. A
107
+ // diagnostic note such as `$!.name-missing` is one too, though it is not
108
+ // flagged, so it is answered rather than replaced by the receiver (011.20).
109
+ if (result.isFailedResult() || result.referent().isError())
107
110
  return result;
108
111
  return this.isMutating() ? state.receiver : result;
109
112
  }
@@ -0,0 +1,64 @@
1
+ import { Frame } from "./frame.js";
2
+ import { FrameCount } from "./frame-count.js";
3
+ import { FrameInt } from "./frame-int.js";
4
+ let construct;
5
+ /**
6
+ * Installs what `.####` answers a present Demi with. The Demi is an HC class,
7
+ * `Demi` in `hc/demi.hc`, so the frames package, which cannot run HC, takes
8
+ * its constructor from the evaluator (`lib/execute/demi-prologue.ts`).
9
+ *
10
+ * @param constructor The constructor, called once per present observation.
11
+ */
12
+ export function installDemiConstructor(constructor) {
13
+ construct = constructor;
14
+ }
15
+ /**
16
+ * The fourth hash, `.####`, derived only from the existing observers: Count n,
17
+ * Size s and residual r give the loads (s+r)/2 and (s−r)/2, and n's parity
18
+ * the phase. It never folds, executes or caches the source, and reads each
19
+ * observer at most once.
20
+ *
21
+ * In order: a failure of the source or of any observer is answered as it is;
22
+ * no Count (nil) or Count zero is nil; nil residual is nil; observations that
23
+ * are not exact Counts and an integer are `$!.demi-observations`; and loads
24
+ * that are negative or not whole are `$!.demi-coherence`. Only then is the
25
+ * Demi constructed (011.18b–m).
26
+ *
27
+ * @param source The observed Frame.
28
+ * @returns A Demi, nil, or an error.
29
+ */
30
+ export function observeDemi(source) {
31
+ const failure = source.observationError();
32
+ if (failure)
33
+ return failure;
34
+ const n = source.sizeFor(Frame.kCOUNT);
35
+ if (n.observationError())
36
+ return n;
37
+ if (n === Frame.nil)
38
+ return Frame.nil; // no Count, no Demi (011.18k)
39
+ if (!(n instanceof FrameCount) || typeof n.data !== "bigint" || n.data < 0n) {
40
+ return Frame.error("$!.demi-count");
41
+ }
42
+ if (n.data === 0n)
43
+ return Frame.nil;
44
+ const s = source.sizeFor(Frame.kLEAVES);
45
+ if (s.observationError())
46
+ return s;
47
+ const r = source.sizeFor(Frame.kRESIDUAL);
48
+ if (r.observationError())
49
+ return r;
50
+ if (r === Frame.nil)
51
+ return Frame.nil;
52
+ if (!(s instanceof FrameCount) || !(r instanceof FrameInt) ||
53
+ typeof s.data !== "bigint" || typeof r.data !== "bigint" || s.data < 0n)
54
+ return Frame.error("$!.demi-observations");
55
+ const sum = s.data + r.data;
56
+ const difference = s.data - r.data;
57
+ if (sum < 0n || difference < 0n || sum % 2n !== 0n || difference % 2n !== 0n) {
58
+ return Frame.error("$!.demi-coherence");
59
+ }
60
+ if (!construct)
61
+ return Frame.error("$!.demi-unavailable");
62
+ return construct(new FrameCount(n.data % 2n === 0n ? 2n : 1n), new FrameCount(sum / 2n), new FrameCount(difference / 2n));
63
+ }
64
+ Frame.demi = observeDemi;
@@ -135,8 +135,8 @@ export class FrameArray extends FrameList {
135
135
  return true;
136
136
  }
137
137
  /**
138
- * An evaluated array exposes ordered data for residual; properties and
139
- * declared parents are excluded.
138
+ * An array exposes its ordered stored contents for residual; properties
139
+ * and declared parents are excluded. Source forms are not executed.
140
140
  */
141
141
  supportsResidual() {
142
142
  return true;
@@ -219,7 +219,7 @@ export class FrameArray extends FrameList {
219
219
  return replaced;
220
220
  }
221
221
  lookup_here(key, origin) {
222
- if (/^\d+$/.test(key)) {
222
+ if (Frame.isIndexKey(key)) {
223
223
  return this.at(Number(key));
224
224
  }
225
225
  return super.lookup_here(key, origin);
@@ -265,6 +265,86 @@ export class FrameArray extends FrameList {
265
265
  return this;
266
266
  return new BoundMethod(method, this, false, methodEffect(FrameArray.TEXT_KEY)).call(Frame.nil);
267
267
  }
268
+ /**
269
+ * An aggregate observes its elements, so a class that keeps its state in
270
+ * fields observes as its empty element list: Count 0, Size 1, residual 0.
271
+ * One that declares a method named `#`, `##` or `###`, on itself or a
272
+ * declared parent, answers that method's result instead, the way one that
273
+ * declares `apply` decides its own application (011.20). Nothing declares
274
+ * one by default, so every other aggregate observes exactly as before.
275
+ *
276
+ * The answer must be the kind the operator answers: a Count for `#` and
277
+ * `##`, an exact integer for `###`. Anything else is
278
+ * `$!.declared-observation`, an error the method answered is answered as it
279
+ * is, and a method that observes its own receiver the same way, directly
280
+ * or through other declared observations, is `$!.cyclic-observation`.
281
+ * Nesting deeper than `OBSERVATION_DEPTH_LIMIT`, as a method that observes
282
+ * a fresh instance of its own class does, is `$!.observation-depth`.
283
+ *
284
+ * The method runs immutably, so it cannot write its receiver. It is still
285
+ * code the class wrote: it runs on every observation, with no caching, and
286
+ * may act on anything else it can reach, a mutable handle in scope
287
+ * included. Observation is pure only for classes that keep it pure.
288
+ *
289
+ * @param key A size operator.
290
+ * @returns The declared answer, or undefined when none is declared.
291
+ */
292
+ declaredObservation(key) {
293
+ if (!FrameArray.OBSERVATION_KEYS.includes(key))
294
+ return undefined;
295
+ const method = this.declaredMethod(key);
296
+ if (!method)
297
+ return undefined;
298
+ const active = FrameArray.observing.get(this) ?? new Set();
299
+ if (active.has(key))
300
+ return Frame.error(`$!.cyclic-observation .${key}`);
301
+ if (FrameArray.observationDepth >= FrameArray.OBSERVATION_DEPTH_LIMIT) {
302
+ return Frame.error(`$!.observation-depth .${key}`);
303
+ }
304
+ active.add(key);
305
+ FrameArray.observing.set(this, active);
306
+ FrameArray.observationDepth++;
307
+ let answer;
308
+ try {
309
+ answer = new BoundMethod(method, this, false, methodEffect(key)).call(Frame.nil).referent();
310
+ }
311
+ finally {
312
+ FrameArray.observationDepth--;
313
+ active.delete(key);
314
+ if (active.size === 0)
315
+ FrameArray.observing.delete(this);
316
+ }
317
+ const failure = answer.observationError();
318
+ if (failure)
319
+ return failure;
320
+ const data = answer.data;
321
+ const valid = key === Frame.kRESIDUAL
322
+ ? answer.className() === "FrameInt" || answer instanceof FrameCount
323
+ : answer instanceof FrameCount;
324
+ return valid && typeof data === "bigint"
325
+ ? answer
326
+ : Frame.error(`$!.declared-observation .${key}`);
327
+ }
328
+ /** A declared Count, Size or residual first; the list's own rule otherwise. */
329
+ sizeFor(key) {
330
+ const failure = this.observationError();
331
+ if (failure && Frame.SIZE_OPERATORS.includes(key))
332
+ return failure;
333
+ return this.declaredObservation(key) ?? super.sizeFor(key);
334
+ }
335
+ /**
336
+ * A declared Size is also what this aggregate contributes inside another,
337
+ * so `[d, d].##` adds the declared Sizes rather than one terminal for each.
338
+ */
339
+ nativeSize(path) {
340
+ const failure = this.observationError();
341
+ if (failure)
342
+ return failure;
343
+ const declared = this.declaredObservation(Frame.kLEAVES);
344
+ if (declared === undefined)
345
+ return super.nativeSize(path);
346
+ return declared instanceof FrameCount ? declared.data : declared;
347
+ }
268
348
  /**
269
349
  * A method declared under `key` on this aggregate or its declared parents.
270
350
  *
@@ -382,3 +462,43 @@ Object.defineProperty(FrameArray, "TEXT_KEY", {
382
462
  writable: true,
383
463
  value: "toText"
384
464
  });
465
+ /**
466
+ * The size operators an aggregate may declare its own answer to (011.20):
467
+ * Count, Size and residual. `.####` is not among them, because it is always
468
+ * derived from these three, so a class that declares them gets it for free.
469
+ */
470
+ Object.defineProperty(FrameArray, "OBSERVATION_KEYS", {
471
+ enumerable: true,
472
+ configurable: true,
473
+ writable: true,
474
+ value: [
475
+ Frame.kCOUNT,
476
+ Frame.kLEAVES,
477
+ Frame.kRESIDUAL,
478
+ ]
479
+ });
480
+ /** Declared observations in progress, so one that reads itself fails. */
481
+ Object.defineProperty(FrameArray, "observing", {
482
+ enumerable: true,
483
+ configurable: true,
484
+ writable: true,
485
+ value: new Map()
486
+ });
487
+ /**
488
+ * How deeply declared observations may nest. A cycle through the same
489
+ * receivers is caught exactly; one that builds a fresh receiver each step
490
+ * is not, so nesting is bounded too, far above any real class's need.
491
+ */
492
+ Object.defineProperty(FrameArray, "OBSERVATION_DEPTH_LIMIT", {
493
+ enumerable: true,
494
+ configurable: true,
495
+ writable: true,
496
+ value: 32
497
+ });
498
+ /** Declared observations now running, across every receiver. */
499
+ Object.defineProperty(FrameArray, "observationDepth", {
500
+ enumerable: true,
501
+ configurable: true,
502
+ writable: true,
503
+ value: 0
504
+ });
@@ -4,6 +4,16 @@ export class FrameAtom extends Frame {
4
4
  constructor(meta = NilContext) {
5
5
  super(meta);
6
6
  }
7
+ /**
8
+ * A void atom, such as a comment, keeps an explicit Count zero; only nil
9
+ * itself has no Count (011.18k).
10
+ */
11
+ sizeFor(key) {
12
+ if (key === Frame.kCOUNT && this.is.void) {
13
+ return this.observationError() ?? Frame.count(0n);
14
+ }
15
+ return super.sizeFor(key);
16
+ }
7
17
  string_prefix() {
8
18
  return "";
9
19
  }
@@ -32,13 +32,18 @@ export class FrameCount extends FrameInt {
32
32
  }
33
33
  }
34
34
  /**
35
- * A count is its own size, so `.#` and `.##` both answer it (#411). A count
36
- * is not a Figure, so `.###` answers nil, as for any atom (010.04). The
37
- * spelling is the literal `Frame.kRESIDUAL`, since this module imports
38
- * `Frame` as a type only.
35
+ * A count is its own immediate count and Size (#411). Its residual, Count
36
+ * parity n mod 2, comes from the base Frame rule (011.18k, 011.18m).
37
+ * Unknown keys must not inherit the old accidental Count fallback.
39
38
  */
40
39
  sizeFor(key) {
41
- return key === "###" ? super.sizeFor(key) : this;
40
+ switch (key) {
41
+ case Frame.kCOUNT:
42
+ case Frame.kLEAVES:
43
+ return this;
44
+ default:
45
+ return super.sizeFor(key);
46
+ }
42
47
  }
43
48
  promoteOne() {
44
49
  return new FrameInt(this.data);
@@ -112,11 +112,14 @@ export class FrameExpr extends FrameList {
112
112
  const value = item.in(resumedScope(item, scope));
113
113
  if (value.is.error === true)
114
114
  return value;
115
+ if (index === 0 && value.isSymbol() && value.is.address &&
116
+ Frame.SIZE_OPERATORS.includes(value.spelling()))
117
+ return value;
115
118
  // An explicit nil receiver still has a Size. The initial nil accumulator
116
119
  // is not a receiver, so a leading .## remains an address (#411).
117
120
  if (index > 0 && sum.is.void && value.isSymbol() &&
118
121
  value.is.address &&
119
- [Frame.kLEAVES, Frame.kRESIDUAL].includes(value.spelling())) {
122
+ Frame.SIZE_OPERATORS.includes(value.spelling())) {
120
123
  return value.called_by(sum);
121
124
  }
122
125
  if (index > 0 && value.is.operator === true) {
@@ -152,8 +152,14 @@ export class FrameHandle extends Frame {
152
152
  links.push(this.target.parent);
153
153
  return links;
154
154
  }
155
+ /**
156
+ * A closure found under a field is a method of the target, so it answers
157
+ * bound to it. One found under an element index is data the target holds,
158
+ * so it answers as itself, as it does when read from a literal or by
159
+ * iteration: `xs.0 === C` holds for `.xs [C]`.
160
+ */
155
161
  lookup_result(value, key) {
156
- if (value.isClosure()) {
162
+ if (value.isClosure() && !Frame.isIndexKey(key)) {
157
163
  const effect = methodEffect(key);
158
164
  if (effect.mutating && this.mutable)
159
165
  this.copyOnWriteTarget();
@@ -216,3 +216,4 @@ Object.defineProperty(FrameInt, "NUMBER_CHAR", {
216
216
  writable: true,
217
217
  value: /\d/
218
218
  });
219
+ Frame.signed = (value) => new FrameInt(value);
@@ -98,9 +98,9 @@ export class FrameLazy extends FrameExpr {
98
98
  /**
99
99
  * `.#` counts the body's represented words (#429). `.##` sums their native
100
100
  * Sizes without execution or evaluation-site registration; an empty body
101
- * retains Size 1. A closure's words are executable syntax, so it has no
102
- * ordered data plane for `.###` and answers nil (010.08). The operator
103
- * reaches a closure as its argument and is answered before its body runs.
101
+ * retains Size 1. Residual alternates complete stored-word Sizes; Demi
102
+ * derives from those observations (011.18c). The operator reaches a closure
103
+ * as its argument and is answered before its body runs.
104
104
  */
105
105
  sizeOperator(argument) {
106
106
  if (argument instanceof FrameSymbol && argument.is.address === true &&
@@ -144,13 +144,22 @@ export class FrameList extends Frame {
144
144
  }
145
145
  /** Immediate count is unchanged; Size and residual share native child sizes. */
146
146
  sizeFor(key) {
147
+ const failure = this.observationError();
148
+ if (failure && Frame.SIZE_OPERATORS.includes(key))
149
+ return failure;
147
150
  if (key === Frame.kCOUNT) {
148
- return new FrameCount(BigInt(this.countedElements().length));
151
+ const elements = this.sizeElements();
152
+ return elements instanceof Frame
153
+ ? elements
154
+ : new FrameCount(BigInt(elements.length));
149
155
  }
150
156
  return key === Frame.kRESIDUAL ? this.residual() : super.sizeFor(key);
151
157
  }
152
158
  /** Empty aggregates retain one terminal; shared descendants count per occurrence. */
153
159
  nativeSize(path) {
160
+ const failure = this.observationError();
161
+ if (failure)
162
+ return failure;
154
163
  if (path.has(this))
155
164
  return Frame.error("$!.cyclic-aggregate .##");
156
165
  path.add(this);
@@ -173,21 +182,24 @@ export class FrameList extends Frame {
173
182
  path.delete(this);
174
183
  }
175
184
  }
176
- /** Only concrete ordered data hosts opt in, never executable/matcher syntax. */
185
+ /** Lists observe stored contents; schemas retain their separate semantics. */
177
186
  supportsResidual() {
178
- return false;
187
+ return true;
179
188
  }
180
189
  /** Alternate over immediate positions, using each child's complete Size. */
181
190
  residual() {
182
- if (!this.supportsResidual() || this.is.source === true)
191
+ if (!this.supportsResidual())
183
192
  return Frame.nil;
193
+ const elements = this.sizeElements();
194
+ if (elements instanceof Frame)
195
+ return elements;
184
196
  const path = new Set([this]);
185
197
  let signed = 0n;
186
198
  let positive = true;
187
- for (const element of this.countedElements()) {
199
+ for (const element of elements) {
188
200
  const size = element.referent().nativeSize(path);
189
201
  if (typeof size !== "bigint")
190
- return Frame.nil;
202
+ return size;
191
203
  signed += positive ? size : -size;
192
204
  positive = !positive;
193
205
  }
@@ -27,8 +27,8 @@ const recognizeName = (symbol, source = "") => {
27
27
  return { disposition: ScanDisposition.CompleteRedispatch };
28
28
  }
29
29
  // `#` begins a comment except where it spells a size operator, `.#`, `.##`
30
- // or `.###` (#411, 010.04), which nothing extends: `.foo#bar` still ends at
31
- // its `#`, and `.####` is `.###` before a comment.
30
+ // `.###` or `.####` (011.18). A fifth hash starts a comment;
31
+ // `.foo#bar` still ends at its first hash.
32
32
  if (Frame.SIZE_OPERATORS.includes(source + char)) {
33
33
  return { disposition: ScanDisposition.Consume };
34
34
  }
@@ -51,6 +51,14 @@ export class FrameNote extends FrameAtom {
51
51
  this.setLabel(data, source);
52
52
  this.id += this.data;
53
53
  }
54
+ /** A diagnostic failure is an error value, though not flagged as one. */
55
+ isError() {
56
+ return super.isError() || this.isDiagnosticFailure();
57
+ }
58
+ /** Observations preserve diagnostic failures as values. */
59
+ observationError() {
60
+ return this.isDiagnosticFailure() ? this : super.observationError();
61
+ }
54
62
  /** Diagnostic notes that represent failures, rather than test progress. */
55
63
  isDiagnosticFailure() {
56
64
  return ["!", "<>", ">", "-"].includes(this.data);
@@ -81,7 +81,16 @@ export function projectBigIntRatio(numerator, denominator) {
81
81
  }
82
82
  /** Shared rank-based numeric dispatch and unary/apply behavior. */
83
83
  export class FrameNumeric extends FrameAtom {
84
+ observationError() {
85
+ return super.observationError() ??
86
+ (this.rank === NUMERIC_RANK.number && !Number.isFinite(this.valueOf())
87
+ ? Frame.error("$!.nonquantifiable-size .##")
88
+ : undefined);
89
+ }
84
90
  nativeSize(path) {
91
+ const failure = this.observationError();
92
+ if (failure)
93
+ return failure;
85
94
  // Dimensional and dotted values have no implicit unit or magnitude.
86
95
  if (this.rank === null)
87
96
  return super.nativeSize(path);
@@ -62,6 +62,9 @@ export class FrameSchema extends FrameList {
62
62
  }
63
63
  return this;
64
64
  }
65
+ supportsResidual() {
66
+ return false;
67
+ }
65
68
  nativeSize() {
66
69
  // Empty enumeration means the total type, not an empty finite domain.
67
70
  // Inspect the installed matcher only; never traverse/compile candidates.