eyeprolog 1.2.15 → 1.2.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.2.15",
6
+ "version": "1.2.16",
7
7
  "description": "EyeProlog turns facts and rules into answers and proofs.",
8
8
  "type": "module",
9
9
  "main": "./index.js",
package/src/solver.js CHANGED
@@ -490,10 +490,11 @@ function normalizeHostResourceError(error) {
490
490
  const message = String(error?.message ?? '');
491
491
  // V8 reports exhausted Map/Set capacity as a host RangeError. ISO 7.12.2 h
492
492
  // requires processor resource exhaustion to surface as resource_error/1,
493
- // with the resource atom implementation dependent. EyeProlog uses the
494
- // finite_memory spelling already accepted by its ISO conformance corpus.
493
+ // with the resource atom implementation dependent. A finite host capacity
494
+ // ceiling is reported as `memory`; reserve `finite_memory` for the separate
495
+ // convention where no finite amount of memory can complete the computation.
495
496
  if (/^(?:Map|Set) maximum size exceeded$/.test(message)) {
496
- return new PrologError('resource_error(finite_memory)');
497
+ return new PrologError('resource_error(memory)');
497
498
  }
498
499
  return error;
499
500
  }
@@ -2221,22 +2221,27 @@ open(X) :- candidate(X), \\+ closed(X).
2221
2221
  },
2222
2222
  },
2223
2223
  {
2224
- name: 'host Map capacity errors become ISO resource errors',
2224
+ name: 'host Map/Set capacity errors become resource_error(memory)',
2225
2225
  run: () => {
2226
- const registry = new BuiltinRegistry();
2227
- registry.add('exhaust_map', 0, function* () {
2228
- throw new RangeError('Map maximum size exceeded');
2229
- });
2230
- const solver = new Solver(Program.parse(''), { registry });
2231
- const goal = parseGoalText('exhaust_map');
2232
- let caught = null;
2233
- try {
2234
- [...solver.solve([goal], new Env(), 0)];
2235
- } catch (error) {
2236
- caught = error;
2226
+ for (const [predicate, message] of [
2227
+ ['exhaust_map', 'Map maximum size exceeded'],
2228
+ ['exhaust_set', 'Set maximum size exceeded'],
2229
+ ]) {
2230
+ const registry = new BuiltinRegistry();
2231
+ registry.add(predicate, 0, function* () {
2232
+ throw new RangeError(message);
2233
+ });
2234
+ const solver = new Solver(Program.parse(''), { registry });
2235
+ const goal = parseGoalText(predicate);
2236
+ let caught = null;
2237
+ try {
2238
+ [...solver.solve([goal], new Env(), 0)];
2239
+ } catch (error) {
2240
+ caught = error;
2241
+ }
2242
+ assertEqual(caught?.name, 'PrologError', `${predicate} normalized error type`);
2243
+ assertEqual(caught?.formal, 'resource_error(memory)', `${predicate} normalized resource error`);
2237
2244
  }
2238
- assertEqual(caught?.name, 'PrologError', 'normalized error type');
2239
- assertEqual(caught?.formal, 'resource_error(finite_memory)', 'normalized resource error');
2240
2245
  },
2241
2246
  },
2242
2247
  {
@@ -1823,8 +1823,12 @@ sorted-list operation. No process-global variable registry or creation ordinal
1823
1823
  is retained or exposed through later comparisons.
1824
1824
 
1825
1825
  Host capacity failures that V8 reports as `Map maximum size exceeded` or `Set`
1826
- `maximum size exceeded` are normalized at the solver boundary to the ISO error
1827
- `resource_error(finite_memory)` instead of leaking a JavaScript `RangeError`.
1826
+ `maximum size exceeded` are normalized at the solver boundary to
1827
+ `resource_error(memory)` instead of leaking a JavaScript `RangeError`. ISO
1828
+ 13211-1 leaves the resource atom implementation dependent. EyeProlog uses
1829
+ `memory` for a finite host allocation/capacity ceiling and reserves the
1830
+ `finite_memory` spelling for the distinct convention where no finite amount of
1831
+ memory could complete the computation.
1828
1832
 
1829
1833
  ### Implementation boundary
1830
1834