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 +1 -1
- package/src/solver.js +4 -3
- package/test/run-regression.mjs +19 -14
- package/the-art-of-eyeprolog.md +6 -2
package/package.json
CHANGED
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.
|
|
494
|
-
//
|
|
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(
|
|
497
|
+
return new PrologError('resource_error(memory)');
|
|
497
498
|
}
|
|
498
499
|
return error;
|
|
499
500
|
}
|
package/test/run-regression.mjs
CHANGED
|
@@ -2221,22 +2221,27 @@ open(X) :- candidate(X), \\+ closed(X).
|
|
|
2221
2221
|
},
|
|
2222
2222
|
},
|
|
2223
2223
|
{
|
|
2224
|
-
name: 'host Map capacity errors become
|
|
2224
|
+
name: 'host Map/Set capacity errors become resource_error(memory)',
|
|
2225
2225
|
run: () => {
|
|
2226
|
-
const
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
caught =
|
|
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
|
{
|
package/the-art-of-eyeprolog.md
CHANGED
|
@@ -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
|
|
1827
|
-
`resource_error(
|
|
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
|
|