eyeprolog 1.3.50 → 1.3.52
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/iso-arithmetic.js +30 -15
- package/src/iso-limits.js +6 -7
- package/src/iso.js +39 -10
- package/src/parser.js +3 -1
- package/src/program.js +6 -1
- package/src/solver.js +4 -2
- package/test/conformance/ISO-COMPLIANCE.md +48 -22
- package/test/conformance/ISO-IMPLEMENTATION-DEFINED.md +1 -1
- package/test/conformance/ISO-MATRIX.md +3 -3
- package/test/conformance/STC-DRAFT-STATUS.md +7 -3
- package/test/conformance/expected/iso/exceptions_and_flags.pl +1 -1
- package/test/run-iso-strict.mjs +88 -14
- package/the-art-of-eyeprolog.md +1 -1
package/package.json
CHANGED
package/src/iso-arithmetic.js
CHANGED
|
@@ -5,6 +5,19 @@ import {
|
|
|
5
5
|
} from './term.js';
|
|
6
6
|
import { PrologError } from './errors.js';
|
|
7
7
|
|
|
8
|
+
function integerResource(operation) {
|
|
9
|
+
try {
|
|
10
|
+
return operation();
|
|
11
|
+
} catch (error) {
|
|
12
|
+
// With bounded=false, integer operations have no language-level numeric
|
|
13
|
+
// representation bound. A finite host can nevertheless exhaust storage
|
|
14
|
+
// (V8 reports oversized BigInt powers/shifts as RangeError). Keep that
|
|
15
|
+
// implementation resource boundary inside the ISO error model.
|
|
16
|
+
if (error?.name === 'RangeError') throw new PrologError('resource_error(memory)');
|
|
17
|
+
throw error;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
8
21
|
function evaluate(term, env, options = {}) {
|
|
9
22
|
term = deref(term, env);
|
|
10
23
|
if (term.type === VAR) throw new PrologError('instantiation_error');
|
|
@@ -117,7 +130,7 @@ function evaluateOperation(term, args, options = {}) {
|
|
|
117
130
|
throw new PrologError('type_error(integer)', numericTerm(invalid));
|
|
118
131
|
}
|
|
119
132
|
if (bothInteger && name === '^') {
|
|
120
|
-
if (b >= 0n) return { integer: true, value: a ** b };
|
|
133
|
+
if (b >= 0n) return { integer: true, value: integerResource(() => a ** b) };
|
|
121
134
|
if (a === 0n) throw new PrologError('evaluation_error(undefined)');
|
|
122
135
|
if (a === 1n) return { integer: true, value: 1n };
|
|
123
136
|
if (a === -1n) return { integer: true, value: (-b) % 2n === 0n ? 1n : -1n };
|
|
@@ -126,22 +139,24 @@ function evaluateOperation(term, args, options = {}) {
|
|
|
126
139
|
}
|
|
127
140
|
if (bothInteger && ['+', '-', '*', '//', 'div', 'mod', 'rem', '/\\', '\\/', 'xor', '<<', '>>'].includes(name)) {
|
|
128
141
|
if ((name === '//' || name === 'div' || name === 'mod' || name === 'rem') && b === 0n) throw new PrologError('evaluation_error(zero_divisor)');
|
|
129
|
-
if (name === '+') return { integer: true, value: a + b };
|
|
130
|
-
if (name === '-') return { integer: true, value: a - b };
|
|
131
|
-
if (name === '*') return { integer: true, value: a * b };
|
|
132
|
-
if (name === '//') return { integer: true, value: a / b };
|
|
142
|
+
if (name === '+') return { integer: true, value: integerResource(() => a + b) };
|
|
143
|
+
if (name === '-') return { integer: true, value: integerResource(() => a - b) };
|
|
144
|
+
if (name === '*') return { integer: true, value: integerResource(() => a * b) };
|
|
145
|
+
if (name === '//') return { integer: true, value: integerResource(() => a / b) };
|
|
133
146
|
if (name === 'div') {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
147
|
+
return { integer: true, value: integerResource(() => {
|
|
148
|
+
const quotient = a / b;
|
|
149
|
+
const remainder = a % b;
|
|
150
|
+
return remainder !== 0n && ((a < 0n) !== (b < 0n)) ? quotient - 1n : quotient;
|
|
151
|
+
}) };
|
|
137
152
|
}
|
|
138
|
-
if (name === 'rem') return { integer: true, value: a % b };
|
|
139
|
-
if (name === 'mod') return { integer: true, value: ((a % b) + b) % b };
|
|
140
|
-
if (name === '/\\') return { integer: true, value: a & b };
|
|
141
|
-
if (name === '\\/') return { integer: true, value: a | b };
|
|
142
|
-
if (name === 'xor') return { integer: true, value: a ^ b };
|
|
143
|
-
if (name === '<<') return { integer: true, value: a << b };
|
|
144
|
-
if (name === '>>') return { integer: true, value: a >> b };
|
|
153
|
+
if (name === 'rem') return { integer: true, value: integerResource(() => a % b) };
|
|
154
|
+
if (name === 'mod') return { integer: true, value: integerResource(() => ((a % b) + b) % b) };
|
|
155
|
+
if (name === '/\\') return { integer: true, value: integerResource(() => a & b) };
|
|
156
|
+
if (name === '\\/') return { integer: true, value: integerResource(() => a | b) };
|
|
157
|
+
if (name === 'xor') return { integer: true, value: integerResource(() => a ^ b) };
|
|
158
|
+
if (name === '<<') return { integer: true, value: integerResource(() => a << b) };
|
|
159
|
+
if (name === '>>') return { integer: true, value: integerResource(() => a >> b) };
|
|
145
160
|
}
|
|
146
161
|
const x = Number(a), y = Number(b);
|
|
147
162
|
if ((!Number.isFinite(x) || !Number.isFinite(y)) && name !== 'max' && name !== 'min') {
|
package/src/iso-limits.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
// ISO/IEC 13211-1 implementation-defined processor limits.
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
|
|
8
|
-
export const ISO_MAX_ARITY = 65535;
|
|
2
|
+
//
|
|
3
|
+
// max_arity describes the maximum arity of *compound terms*, not a separate
|
|
4
|
+
// implementation limit on procedures. EyeProlog does not impose a fixed
|
|
5
|
+
// compound-term arity ceiling: practical exhaustion is a resource issue.
|
|
6
|
+
// Keep null as the internal sentinel for the standard flag value `unbounded`.
|
|
7
|
+
export const ISO_MAX_ARITY = null;
|
package/src/iso.js
CHANGED
|
@@ -404,14 +404,30 @@ function* functorBuiltin({ goal, env }) {
|
|
|
404
404
|
}
|
|
405
405
|
const arity = BigInt(arityTerm.name);
|
|
406
406
|
if (arity > 0n && name.type !== ATOM) throw new PrologError('type_error(atom)', name);
|
|
407
|
-
if (arity > BigInt(ISO_MAX_ARITY))
|
|
407
|
+
if (ISO_MAX_ARITY != null && arity > BigInt(ISO_MAX_ARITY)) {
|
|
408
|
+
throw new PrologError('representation_error(max_arity)');
|
|
409
|
+
}
|
|
408
410
|
if (arity < 0n) throw new PrologError('domain_error(not_less_than_zero)', arityTerm);
|
|
409
411
|
if (arity === 0n) {
|
|
410
412
|
if (unify(goal.args[0], name, next)) yield next;
|
|
411
413
|
return;
|
|
412
414
|
}
|
|
415
|
+
// `max_arity = unbounded` means there is no ISO-visible representation
|
|
416
|
+
// ceiling on compound terms. The JavaScript host still has finite storage
|
|
417
|
+
// resources, however. In particular an Array length is limited to 2^32-1
|
|
418
|
+
// and allocation can fail before that. Report host exhaustion as the ISO
|
|
419
|
+
// resource error family rather than leaking a JavaScript RangeError or
|
|
420
|
+
// reintroducing an artificial max_arity limit.
|
|
421
|
+
if (arity > 0xffffffffn) throw new PrologError('resource_error(memory)');
|
|
413
422
|
const id = ++isoFresh;
|
|
414
|
-
|
|
423
|
+
let args;
|
|
424
|
+
try {
|
|
425
|
+
args = Array.from({ length: Number(arity) }, (_, i) => variable(`__functor${id}_${i}`));
|
|
426
|
+
} catch (error) {
|
|
427
|
+
if (error?.name === 'RangeError') throw new PrologError('resource_error(memory)');
|
|
428
|
+
throw error;
|
|
429
|
+
}
|
|
430
|
+
if (unify(goal.args[0], compound(name.name, args), next)) yield next;
|
|
415
431
|
}
|
|
416
432
|
|
|
417
433
|
function* argBuiltin({ goal, env }) {
|
|
@@ -460,7 +476,9 @@ function* univBuiltin({ goal, env }) {
|
|
|
460
476
|
return;
|
|
461
477
|
}
|
|
462
478
|
const name = requireAtom(items[0], env);
|
|
463
|
-
if (items.length - 1 > ISO_MAX_ARITY)
|
|
479
|
+
if (ISO_MAX_ARITY != null && items.length - 1 > ISO_MAX_ARITY) {
|
|
480
|
+
throw new PrologError('representation_error(max_arity)');
|
|
481
|
+
}
|
|
464
482
|
if (unify(goal.args[0], compound(name.name, items.slice(1)), next)) yield next;
|
|
465
483
|
}
|
|
466
484
|
|
|
@@ -591,12 +609,17 @@ function isGrammarRuleProcedure(solver, head) {
|
|
|
591
609
|
|
|
592
610
|
function isProcessorStaticProcedure(solver, head) {
|
|
593
611
|
// Conjunction is an ISO control construct (7.5/Table 9) but is executed
|
|
594
|
-
// directly by the solver rather than through the builtin registry.
|
|
595
|
-
//
|
|
596
|
-
//
|
|
612
|
+
// directly by the solver rather than through the builtin registry. The
|
|
613
|
+
// source syntax functors (:-)/1-2 likewise have processor-defined roles and
|
|
614
|
+
// STC #56 calls for protecting them from database modification. Keep these
|
|
615
|
+
// in the same static/private family for strict runtime database operations.
|
|
616
|
+
const strictSyntaxProcedure = solver.isoStrict && (
|
|
617
|
+
(head.name === ',' && head.arity === 2) ||
|
|
618
|
+
(head.name === ':-' && (head.arity === 1 || head.arity === 2))
|
|
619
|
+
);
|
|
597
620
|
return Boolean(solver.registry.get(head.name, head.arity)) ||
|
|
598
621
|
isGrammarRuleProcedure(solver, head) ||
|
|
599
|
-
|
|
622
|
+
strictSyntaxProcedure;
|
|
600
623
|
}
|
|
601
624
|
|
|
602
625
|
function assertModifiable(solver, head, module = 'user') {
|
|
@@ -677,8 +700,14 @@ function predicateIndicatorParts(term, env) {
|
|
|
677
700
|
if (name.type !== ATOM) throw new PrologError('type_error(atom)', name);
|
|
678
701
|
const integer = BigInt(arity.name);
|
|
679
702
|
if (integer < 0n) throw new PrologError('domain_error(not_less_than_zero)', arity);
|
|
680
|
-
if (integer > BigInt(ISO_MAX_ARITY))
|
|
681
|
-
|
|
703
|
+
if (ISO_MAX_ARITY != null && integer > BigInt(ISO_MAX_ARITY)) {
|
|
704
|
+
throw new PrologError('representation_error(max_arity)');
|
|
705
|
+
}
|
|
706
|
+
// Actual clause arities are ordinary JavaScript array lengths. For a very
|
|
707
|
+
// large predicate indicator that names no existing procedure, retain the
|
|
708
|
+
// exact integer in the map key instead of rounding it through Number.
|
|
709
|
+
const runtimeArity = integer <= BigInt(Number.MAX_SAFE_INTEGER) ? Number(integer) : integer;
|
|
710
|
+
return { name: name.name, arity: runtimeArity, indicator };
|
|
682
711
|
}
|
|
683
712
|
|
|
684
713
|
function* abolishBuiltin({ solver, goal, env }) {
|
|
@@ -2279,7 +2308,7 @@ function* callClosureBuiltin({ solver, goal, env }) {
|
|
|
2279
2308
|
const closure = callable(goal.args[0], env);
|
|
2280
2309
|
const existing = closure.type === COMPOUND ? closure.args : [];
|
|
2281
2310
|
const extra = goal.args.slice(1);
|
|
2282
|
-
if (existing.length + extra.length > ISO_MAX_ARITY) {
|
|
2311
|
+
if (ISO_MAX_ARITY != null && existing.length + extra.length > ISO_MAX_ARITY) {
|
|
2283
2312
|
throw new PrologError('representation_error(max_arity)');
|
|
2284
2313
|
}
|
|
2285
2314
|
const invoked = compound(closure.name, [...existing, ...extra]);
|
package/src/parser.js
CHANGED
|
@@ -724,7 +724,9 @@ class Parser {
|
|
|
724
724
|
}
|
|
725
725
|
while (true) {
|
|
726
726
|
args.push(this.parseTerm(ARG_MIN_PRECEDENCE, false, false, true));
|
|
727
|
-
if (args.length > ISO_MAX_ARITY)
|
|
727
|
+
if (ISO_MAX_ARITY != null && args.length > ISO_MAX_ARITY) {
|
|
728
|
+
throw new NumberRepresentationError('representation_error(max_arity)');
|
|
729
|
+
}
|
|
728
730
|
if (this.token.type !== TOK.COMMA) break;
|
|
729
731
|
this.advance();
|
|
730
732
|
}
|
package/src/program.js
CHANGED
|
@@ -1317,8 +1317,13 @@ function assertPredicateIsDefinable(name, arity, strictIso = false) {
|
|
|
1317
1317
|
// be redefined in either profile. Strict core mode extends the same ISO
|
|
1318
1318
|
// rule to every Part-1 built-in/control construct; the normal EyeProlog
|
|
1319
1319
|
// profile keeps its historical source-compatibility behavior.
|
|
1320
|
+
const strictSyntaxProcedure = strictIso && (
|
|
1321
|
+
(name === ',' && arity === 2) ||
|
|
1322
|
+
(name === ':-' && (arity === 1 || arity === 2))
|
|
1323
|
+
);
|
|
1320
1324
|
if ((name === 'false' && arity === 0) ||
|
|
1321
|
-
(strictIso &&
|
|
1325
|
+
(strictIso && getStrictIsoRegistry().get(name, arity)) ||
|
|
1326
|
+
strictSyntaxProcedure) {
|
|
1322
1327
|
throw staticProcedureModificationError(name, arity);
|
|
1323
1328
|
}
|
|
1324
1329
|
}
|
package/src/solver.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Depth-first EyeProlog solver with builtin dispatch, memoization, and guarded recursion handling.
|
|
2
2
|
// Most semantic decisions still flow through unification; optimizations only select candidates earlier.
|
|
3
3
|
import {
|
|
4
|
-
COMPOUND, NUMBER, VAR, Env, compactListLength, compactVariableList, compound, cons, copyResolved, deref, emptyList,
|
|
4
|
+
ATOM, COMPOUND, NUMBER, VAR, Env, compactListLength, compactVariableList, compound, cons, copyResolved, deref, emptyList,
|
|
5
5
|
flattenConjunction, freshTerm, isCons, isDecimalInteger, isEmptyList,
|
|
6
6
|
numberTerm, numberTextFromDouble, termIsGround, termToString, unify, variable, variantTerms,
|
|
7
7
|
} from './term.js';
|
|
@@ -962,7 +962,9 @@ function defaultPrologFlags(unknown = 'error', strictIso = false) {
|
|
|
962
962
|
['debug', { value: compound('off', []), allowed: ['on', 'off'], changeable: true }],
|
|
963
963
|
['max_integer', { value: null, allowed: [], changeable: false }],
|
|
964
964
|
['min_integer', { value: null, allowed: [], changeable: false }],
|
|
965
|
-
['max_arity',
|
|
965
|
+
['max_arity', ISO_MAX_ARITY == null
|
|
966
|
+
? { value: compound('unbounded', []), allowed: ['unbounded'], valueType: ATOM, changeable: false }
|
|
967
|
+
: { value: numberTerm(ISO_MAX_ARITY), allowed: [String(ISO_MAX_ARITY)], valueType: NUMBER, changeable: false }],
|
|
966
968
|
['unknown', { value: compound(unknown, []), allowed: ['error', 'fail', 'warning'], changeable: true }],
|
|
967
969
|
['double_quotes', { value: compound('chars', []), allowed: ['chars', 'codes', 'atom'], changeable: true }],
|
|
968
970
|
['occurs_check', { value: compound('true', []), allowed: ['true', 'error'], changeable: true }],
|
|
@@ -31,17 +31,17 @@ error-ordering alternative to an individual executable assertion.
|
|
|
31
31
|
| Standard area | Status | Current evidence |
|
|
32
32
|
| --- | --- | --- |
|
|
33
33
|
| Clause 6 — tokens, terms, lists, operators, quoted text | audit | Complete vendored WG17 syntax matrix, `lexical_and_curly_terms`, `scryer_lexical_terms`, operator suites, syntax-error cases, quoted-layout/escape error cases, writer/read-back regressions, and strict ASCII PCS/collation boundary tests. The implementation-defined 6.5/6.6 character-model decisions are now closed; wider shall-by-shall lexical mapping remains open. |
|
|
34
|
-
| 7.1-7.3 — term types, term order, unification | audit | Standard-order, identity, finite-tree and occurs-check suites, Corrigendum 2 term predicates, plus strict checks for the required `variable < float < integer < atom < compound` type order, PCS-based atom collation, and the
|
|
34
|
+
| 7.1-7.3 — term types, term order, unification | audit | Standard-order, identity, finite-tree and occurs-check suites, Corrigendum 2 term predicates, plus strict checks for the required `variable < float < integer < atom < compound` type order, PCS-based atom collation, and the `max_arity=unbounded` compound-term model. |
|
|
35
35
|
| 7.4 — Prolog text and directives | audit | All Part 1 directive indicators are parsed; include/ensure-loaded/operator/flag/character-conversion behavior has executable coverage. Preparation-time `char_conversion/2` affects later unquoted source text and respects `char_conversion=off`. Strict preparation now enforces declaration-before-clause ordering for `dynamic/1`, `multifile/1`, and `discontiguous/1`, cross-text `multifile/1`, discontiguous clause grouping, empty declared procedures, include textual-replacement behavior, and one-time initialization per prepared program. The remaining shall-by-shall mapping is still open. |
|
|
36
|
-
| 7.5-7.6 — database and term/clause conversion | audit | Dynamic database and logical-update-view suites. Strict mode restores Part 1 private-static/public-dynamic `clause/2` access; focused strict checks now cover `current_predicate/1`, `clause/2`, `asserta/1`, `assertz/1`, `retract/1`, Corrigendum 2 `retractall/1`, and `abolish/1` errors plus empty-procedure lifetime
|
|
36
|
+
| 7.5-7.6 — database and term/clause conversion | audit | Dynamic database and logical-update-view suites. Strict mode restores Part 1 private-static/public-dynamic `clause/2` access; focused strict checks now cover `current_predicate/1`, `clause/2`, `asserta/1`, `assertz/1`, `retract/1`, Corrigendum 2 `retractall/1`, and `abolish/1` errors plus empty-procedure lifetime. Runtime protection includes the solver-native conjunction control construct `','/2` and, following STC #56's accepted-direction action item, the source syntax functors `(:-)/1-2` for database modification/private access while leaving their call behavior distinct. The remaining clause-conversion shall-by-shall mapping is still open. |
|
|
37
37
|
| 7.7 — execution and backtracking | audit | Control/search suites. Strict mode disables EyeProlog automatic tabling, cycle guards, and recursive numeric shortcuts so core execution uses ordinary clause selection/backtracking. |
|
|
38
38
|
| 7.8 — control constructs and exceptions | audit | call, cut, conjunction, disjunction (including failed branches after callee-local cuts), if-then, catch/throw, renamed-copy tests. |
|
|
39
|
-
| 7.9 — expression evaluation | audit | Arithmetic/evaluation/error suites, including Corrigenda. Strict mode now also pins direct-variable precedence, arithmetic operand type errors, float-only rounding conversions, zero-to-negative-power undefined errors, and the Part 1 mixed integer/float comparison conversion rule. Exceptional-value/error-precedence mapping remains to be exhaustively enumerated. |
|
|
39
|
+
| 7.9 — expression evaluation | audit | Arithmetic/evaluation/error suites, including Corrigenda. Strict mode now also pins direct-variable precedence, arithmetic operand type errors, float-only rounding conversions, zero-to-negative-power undefined errors, and the Part 1 mixed integer/float comparison conversion rule. Unbounded integer powers/shifts no longer leak host `RangeError`; finite-host exhaustion is normalized to `resource_error(memory)` in line with the Part 1 resource-error note and STC #21. Exceptional-value/error-precedence mapping remains to be exhaustively enumerated. |
|
|
40
40
|
| 7.10 — input/output concepts | audit | Stream, character/byte I/O, read/write options, operator-sensitive write-back, and Corrigendum 3 writer cases. The audit now also covers write-mode creation/truncation, append creation, repositioned overwrite, flushing, EOF actions, close/current-stream handling, strict stream-position terms, stream-property validation, stream-term requirements, text-vs-binary permission errors, and the prescribed `alias(A)` culprit for `open/4` alias collisions. The full option/mode cross-product is still being mapped. |
|
|
41
41
|
| 7.11 — flags | covered | The complete Part 1 flag set, selected defaults, standard value domains, changeability, `current_prolog_flag/2`, and `set_prolog_flag/2` error behavior have dedicated strict tests. EyeProlog selects `bounded=false` and `integer_rounding_function=toward_zero`; valid alternative values of those fixed flags reach `permission_error(modify,flag,...)`, while `max_integer` and `min_integer` have no current value. Strict mode excludes the EyeProlog `occurs_check` extension. |
|
|
42
|
-
| 7.12 — errors | audit | ISO `error(Error, Context)` envelope, type/domain/permission/representation/evaluation/syntax families and focused error cases. Exact ISO 8.14.1-8.14.4 error precedence is covered for `read_term/3`, `write_term/3`, `op/3`, and `current_op/3`; the continuing audit has corrected additional 8.11-8.13 stream/character/byte errors (including the complete `alias(A)` culprit for `open/4` alias collisions), Corrigendum 2 `keysort/2` errors, atomic-conversion list-shape precedence, `arg/3`, `atom_concat/3`, `sub_atom/5`, `char_conversion/2`, runtime control-construct
|
|
43
|
-
| 8.2-8.17 — built-in predicates | audit | Predicate-family coverage is mapped in ISO-MATRIX.md; Corrigendum 2 additions (`subsumes_term/2`, `term_variables/2`, `call/2..8`, `false/0`) are in the strict registry. The audit now includes corrected `keysort/2` variable/non-pair errors, stricter 8.11-8.13 stream and character/byte modes/errors, the 8.14 option/error-order subfamily, closed 8.17 flags,
|
|
44
|
-
| Clause 9 — evaluable functors | audit | Integer/float/rounding/transcendental/bitwise suites and corrigendum cases. Strict mode excludes the EyeProlog-only evaluable atom `e`, retains Corrigendum 2 arithmetic additions, reports unknown zero-arity evaluables with the required `F/0` culprit shape, enforces the Part 1 numeric/integer operand errors and float-only rounding modes, and uses the Part 1 integer-to-float conversion rule for mixed arithmetic comparisons. Normal mode retains EyeProlog's exact mixed-type comparison extension. Host floating-point representation choices remain documented implementation-defined behavior; exhaustive exceptional-value precedence remains open. |
|
|
42
|
+
| 7.12 — errors | audit | ISO `error(Error, Context)` envelope, type/domain/permission/representation/evaluation/syntax/resource families and focused error cases. Exact ISO 8.14.1-8.14.4 error precedence is covered for `read_term/3`, `write_term/3`, `op/3`, and `current_op/3`; the continuing audit has corrected additional 8.11-8.13 stream/character/byte errors (including the complete `alias(A)` culprit for `open/4` alias collisions), Corrigendum 2 `keysort/2` errors, atomic-conversion list-shape precedence, `arg/3`, `atom_concat/3`, `sub_atom/5`, `char_conversion/2`, runtime control-construct/database protection, arithmetic culprit/precedence reporting, and host-resource normalization for unbounded term/integer operations. A complete one-row-per-prescribed-error ordering map remains open. |
|
|
43
|
+
| 8.2-8.17 — built-in predicates | audit | Predicate-family coverage is mapped in ISO-MATRIX.md; Corrigendum 2 additions (`subsumes_term/2`, `term_variables/2`, `call/2..8`, `false/0`) are in the strict registry. The audit now includes corrected `keysort/2` variable/non-pair errors, stricter 8.11-8.13 stream and character/byte modes/errors, the 8.14 option/error-order subfamily, closed 8.17 flags, additional prescribed precedence for `arg/3`, `atom_concat/3`, `sub_atom/5`, number/atom list conversions, and `char_conversion/2`, plus finite-host resource handling for unbounded `functor/3` construction. The remaining mode/error matrix is not yet one-row-per-standard-row. |
|
|
44
|
+
| Clause 9 — evaluable functors | audit | Integer/float/rounding/transcendental/bitwise suites and corrigendum cases. Strict mode excludes the EyeProlog-only evaluable atom `e`, retains Corrigendum 2 arithmetic additions, reports unknown zero-arity evaluables with the required `F/0` culprit shape, enforces the Part 1 numeric/integer operand errors and float-only rounding modes, and uses the Part 1 integer-to-float conversion rule for mixed arithmetic comparisons. Normal mode retains EyeProlog's exact mixed-type comparison extension. Unbounded BigInt resource exhaustion is translated into the Prolog error model rather than leaking host exceptions. Host floating-point representation choices remain documented implementation-defined behavior; exhaustive exceptional-value precedence remains open. |
|
|
45
45
|
| Corrigendum 1 | covered | Double-quoted atom/operator-priority corrections have dedicated cases. |
|
|
46
46
|
| Corrigendum 2 | covered | Added predicates/functors, catch corrections, bar/operator and uninstantiation corrections have dedicated cases. |
|
|
47
47
|
| Corrigendum 3 | covered | Writer options, `variable_names/1`, canonical list output and negative-power corrections have dedicated cases. |
|
|
@@ -70,14 +70,17 @@ The complete WG17 syntax matrix remains green under this narrower strict
|
|
|
70
70
|
boundary.
|
|
71
71
|
|
|
72
72
|
|
|
73
|
-
The subsequent audit
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
73
|
+
The subsequent arity audit originally selected a finite `max_arity=65535`, but
|
|
74
|
+
issue #66 and the post-Corrigendum STC review exposed that as the wrong
|
|
75
|
+
abstraction: Part 1 `max_arity` is the maximum arity of **compound terms**, not
|
|
76
|
+
a procedure-arity limit. EyeProlog now again selects `max_arity=unbounded` and
|
|
77
|
+
removes the artificial 65535 checks from source parsing, `functor/3`, `=../2`,
|
|
78
|
+
predicate indicators, and Corrigendum 2 `call/N` closure expansion. Practical
|
|
79
|
+
host exhaustion remains a resource condition rather than a declared term-arity
|
|
80
|
+
boundary. Focused strict tests also lock the corrected 8.5 term-construction
|
|
81
|
+
errors, 8.8 clause-access precedence, 8.10 all-solutions goal/list precedence,
|
|
82
|
+
database update errors, and Corrigendum 3 variable metadata traversal/write
|
|
83
|
+
naming.
|
|
81
84
|
|
|
82
85
|
The public WG17 `number_chars/2` comparison used in preparation of Corrigendum
|
|
83
86
|
2 has additionally been checked against the current strict profile. That
|
|
@@ -110,14 +113,13 @@ EyeProlog-only evaluable atom `e`, while the Corrigendum arithmetic additions
|
|
|
110
113
|
remain available. These corrections narrow the remaining `audit` rows but do
|
|
111
114
|
not by themselves close the full shall-by-shall/error-order exit criteria.
|
|
112
115
|
|
|
113
|
-
The next Corrigendum 2 pass
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
`
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
both behaviors.
|
|
116
|
+
The next Corrigendum 2 pass closed the prescribed `call/2..8` max-arity
|
|
117
|
+
branch for processors with a finite `max_arity`, and corrected reverse
|
|
118
|
+
`atom_chars/2` / `atom_codes/2` improper-list culprits. After issue #66 restored
|
|
119
|
+
EyeProlog's selected `max_arity=unbounded`, the conditional `call/N`
|
|
120
|
+
`representation_error(max_arity)` branch is intentionally unreachable unless a
|
|
121
|
+
future processor profile selects a finite compound-term limit; closure
|
|
122
|
+
expansion itself remains covered by strict regressions.
|
|
121
123
|
|
|
122
124
|
|
|
123
125
|
The following Part 1 pass tightens more of the still-open prescribed-error and
|
|
@@ -135,6 +137,30 @@ its exact cross-type comparison as an extension. Dedicated strict regressions
|
|
|
135
137
|
cover these distinctions without changing the normal-profile arithmetic error
|
|
136
138
|
contract.
|
|
137
139
|
|
|
140
|
+
## Post-Corrigendum STC cross-check
|
|
141
|
+
|
|
142
|
+
The public WG17 STC draft is tracked as useful defect-discovery material, but it
|
|
143
|
+
is not silently treated as a fourth published Corrigendum. The current audit
|
|
144
|
+
confirms EyeProlog already has the behavior implicated by the substantive STC
|
|
145
|
+
items on negative-number layout/operator syntax, arithmetic instantiation
|
|
146
|
+
precedence, EOF actions/end tokens, character/code/byte output error overlap,
|
|
147
|
+
clause head/body variable identity, sequential `op/3` and `set_prolog_flag/2`
|
|
148
|
+
preparation effects, integer-to-float transcendental evaluation, `char_code/2`
|
|
149
|
+
type precedence, `read_term/3` EOF handling, mixed arithmetic comparison,
|
|
150
|
+
`integer_rounding_function=toward_zero`, `set_prolog_flag/2` variable errors,
|
|
151
|
+
and `bagof/3` answer order. STC #21 is also used to keep finite-host exhaustion
|
|
152
|
+
of unbounded integer operations inside the Prolog resource-error model.
|
|
153
|
+
|
|
154
|
+
Issue #66 corresponds to the newer STC arity discussion: `max_arity` describes
|
|
155
|
+
compound terms. EyeProlog therefore selects `unbounded` and does not invent a
|
|
156
|
+
finite predicate/procedure ceiling merely to preserve the former 65535 value.
|
|
157
|
+
STC #56, which became a WG17 action item, is implemented narrowly for database
|
|
158
|
+
protection: `(:-)/1-2` are static/private for modification and `clause/2`
|
|
159
|
+
access, while ordinary calls retain their separate existence behavior. Other
|
|
160
|
+
draft/editorial or deliberately controversial proposals (for example deleting
|
|
161
|
+
standalone if-then) remain outside the Part 1 + Corrigenda 1-3 strict baseline
|
|
162
|
+
until standardized or adopted as an explicit compatibility extension.
|
|
163
|
+
|
|
138
164
|
## Strict-core boundary
|
|
139
165
|
|
|
140
166
|
`isoStrict: true` is intentionally a **Part 1 + Corrigenda 1-3** mode. It does
|
|
@@ -65,7 +65,7 @@ Status values are:
|
|
|
65
65
|
| 9.1.3.1 | Integer division rounding function `rndI` | Truncation toward zero, matching the `integer_rounding_function=toward_zero` flag. | **defined** — BigInt division for `//` in `src/iso-arithmetic.js`. |
|
|
66
66
|
| 7.11.2.1 | Whether preparation-time `Convc` affects execution-time `Convc` | Yes: mappings created while Prolog text is prepared are retained and initialize the solver's execution-time conversion map. | **defined** — `src/parser.js`, `src/program.js`, `src/solver.js`. |
|
|
67
67
|
| 7.11.2.2 | Effect when `debug=on` | The flag is accepted and stored; it does not change goal semantics or enable a debugger. | **defined** — `src/solver.js`; no semantic branch depends on `debug`. |
|
|
68
|
-
| 7.11.2.3 | Default `max_arity` | `
|
|
68
|
+
| 7.11.2.3 | Default `max_arity` | `unbounded`: EyeProlog imposes no fixed semantic ceiling on compound-term arity. Practical host allocation exhaustion is a resource condition. This flag is distinct from any potential implementation-specific procedure-arity limit; EyeProlog currently declares no separate finite procedure limit. | **defined** — `src/iso-limits.js`, `src/solver.js`, `src/parser.js`, `src/iso.js`; issue #66 regression coverage. |
|
|
69
69
|
| 7.11.2.5 | Default `double_quotes` | `chars`. | **defined** — `src/solver.js`, parser flag state. |
|
|
70
70
|
| 7.12.1 | Second argument of `error/2` | The default context term is the atom `eyeprolog`. A few implementation-specific diagnostics may deliberately supply a more specific context term. | **defined** — `formalErrorTerm()` in `src/iso.js`. |
|
|
71
71
|
| 7.12.2(f) | Implementation-defined representation limits | Strict character and character-code operations are limited to the selected ASCII PCS/collating integers 0..127. Normal mode extends characters to Unicode scalar values. Arity/integer values are modeled as unbounded but may hit host/resource limits. Float input overflow uses the implementation-specific `max_float`/`min_float` representation names documented by the STC-oriented tests. | **defined** — parser/ISO numeric and character guards. |
|
|
@@ -11,14 +11,14 @@ compliance audit and the remaining work before a full conformance claim.
|
|
|
11
11
|
| Clause 6 lexical and term syntax | tokenizer, operator parser, lists, curly terms, quotes, numeric syntax, comments, strict ASCII PCS/collation | `scryer_lexical_terms`, `lexical_and_curly_terms`, `double_quoted_lists`, `corrigendum1_double_quote_operator`, `wg17_syntax_high_risk`, `wg17_invalid_octal_escape`, `wg17_unterminated_quoted_token`, `wg17_literal_newline_in_quote`, `wg17_non_iso_escape`, strict PCS/collation tests in `run-iso-strict.mjs`, syntax error cases |
|
|
12
12
|
| Clause 7 term order and unification | finite-tree unification, identity, standard order, errors | `unification_control_information`, `swipl_occurs_check`, `term_modes_and_ordering`, `logtalk_compare_standard_order` |
|
|
13
13
|
| Clause 7 control and exceptions | call, cut, conjunction, disjunction, if-then-else, catch and throw | `cut_control`, `control_and_terms`, `exceptions_and_flags`, `corrigenda_catch_callability`, `throw_copies_ball` |
|
|
14
|
-
| 8.2-8.5 term predicates | unification, Corrigendum 2 tests, comparison, sorting, creation and decomposition | `corrigenda_term_predicates`, `corrigenda_sort_keysort`, `logtalk_arg_unification`, `logtalk_univ`, associated error cases, Corrigendum 2 `keysort/2` variable/non-pair errors, and strict `arg/3`, `functor/3` / `=../2` error-order plus
|
|
14
|
+
| 8.2-8.5 term predicates | unification, Corrigendum 2 tests, comparison, sorting, creation and decomposition | `corrigenda_term_predicates`, `corrigenda_sort_keysort`, `logtalk_arg_unification`, `logtalk_univ`, associated error cases, Corrigendum 2 `keysort/2` variable/non-pair errors, and strict `arg/3`, `functor/3` / `=../2` error-order plus unbounded-arity/resource checks |
|
|
15
15
|
| 8.6-8.7 arithmetic predicates | `is/2` and all six arithmetic comparisons | `arithmetic`, comparison cases, isolated evaluation errors |
|
|
16
|
-
| 8.8-8.10 database and solutions | logical update view, dynamic mutation, all-solutions grouping | `dynamic_database`, `trealla_logical_update_view`, `corrigenda_retractall`, `grouped_solutions_and_clauses`, plus strict clause/database error and all-solutions precedence checks, including runtime static/private protection for the solver-native conjunction control construct |
|
|
16
|
+
| 8.8-8.10 database and solutions | logical update view, dynamic mutation, all-solutions grouping | `dynamic_database`, `trealla_logical_update_view`, `corrigenda_retractall`, `grouped_solutions_and_clauses`, plus strict clause/database error and all-solutions precedence checks, including runtime static/private protection for the solver-native conjunction control construct and STC #56 `(:-)/1-2` database protection |
|
|
17
17
|
| 8.11-8.14 streams and term I/O | text/binary streams, properties, units, read/write options and operators | `streams_and_term_io`, `operators`, Corrigendum 3 option cases, stream error cases, strict 8.14.1-8.14.4 option/error-order tests, Corrigendum 3 variable metadata/write naming checks, and issue #65 checks for stream-term/property validation, text-vs-binary permissions, EOF/flush/position, open/close semantics, and the exact `alias(A)` collision culprit |
|
|
18
18
|
| 8.15 logic and control | negation, once, repeat, `call/2` through `call/8`, `false/0` | `logtalk_once`, `corrigenda_call_closure`, `false_builtin`, plus strict Corrigendum 2 resulting-goal `max_arity` error coverage |
|
|
19
19
|
| 8.16 atomic processing | atoms, characters, codes and number conversion with prescribed errors | `atomic_term_processing`, focused forward/reverse cases, parenthesized-number rejection, Logtalk-derived error cases, strict Corrigendum 2 partial/improper-list precedence for atom/number conversions, and prescribed `atom_concat/3` / `sub_atom/5` ordering checks |
|
|
20
20
|
| 8.17 flags and hooks | complete required Part 1 flag set, selected defaults, standard value domains/changeability, halt and character conversion | `exceptions_and_flags`, `remaining_builtins_and_directives`, flag error cases, strict `char_conversion/2` precedence, and the complete strict flag audit in `run-iso-strict.mjs` |
|
|
21
|
-
| Clause 9 evaluable functors | integer, float, rounding, transcendental and bitwise operations | `arithmetic`, `corrigenda_arithmetic`, `corrigenda_atan2_zero`, `corrigenda_integer_negative_power`, strict exclusion of the normal-mode `e` evaluable extension, zero-arity unknown-evaluable checks, prescribed operand/type and negative-power errors, float-only rounding modes,
|
|
21
|
+
| Clause 9 evaluable functors | integer, float, rounding, transcendental and bitwise operations | `arithmetic`, `corrigenda_arithmetic`, `corrigenda_atan2_zero`, `corrigenda_integer_negative_power`, strict exclusion of the normal-mode `e` evaluable extension, zero-arity unknown-evaluable checks, prescribed operand/type and negative-power errors, float-only rounding modes, Part 1 mixed integer/float comparison conversion, and resource-error normalization for finite-host exhaustion of unbounded integer operations |
|
|
22
22
|
| Module compatibility profile (related to ISO/IEC 13211-2 and later WG17 amendment work) | module declarations, exports, imports, qualification, meta-predicate context | `modules/qualified_call`, `modules/selective_library_import`, `dcg_module_nonterminal_indicator` |
|
|
23
23
|
| Part 3-oriented DCG compatibility profile | `-->`, terminal and partial sequences, grammar control constructs, semicontexts, nonterminal indicators, modules, `phrase/2-3`, steadfastness and errors | `dcg_terminals_and_remainder`, `dcg_control_constructs`, `dcg_partial_sequences`, `dcg_phrase_steadfastness`, `dcg_dynamic_nonterminal_indicator`, `logtalk_dcg_phrase_identity`, `logtalk_dcg_semicontexts`, DCG error and precedence cases |
|
|
24
24
|
|
|
@@ -9,7 +9,7 @@ wording.
|
|
|
9
9
|
|
|
10
10
|
The purpose of this ledger is practical. Where an STC item can be expressed as
|
|
11
11
|
an executable Prolog observation, EyeProlog keeps a standards-facing case under
|
|
12
|
-
`test/conformance/stc/` (or points to an existing strict/WG17 case) so discussion
|
|
12
|
+
`test/conformance/cases/stc/` (or points to an existing strict/WG17 case) so discussion
|
|
13
13
|
of the draft can expose implementation problems before they become release
|
|
14
14
|
regressions.
|
|
15
15
|
|
|
@@ -17,14 +17,18 @@ regressions.
|
|
|
17
17
|
|
|
18
18
|
| STC item | Topic | EyeProlog evidence / finding |
|
|
19
19
|
| --- | --- | --- |
|
|
20
|
+
| [#18](https://www.complang.tuwien.ac.at/ulrich/iso-prolog/stc#18) | `eof_action(error)` | Stream regressions verify the first EOF observation yields the EOF value and a subsequent read with `eof_action(error)` raises `permission_error(input,past_end_of_stream,...)`; `eof_code` and `reset` remain distinct. |
|
|
21
|
+
| [#21](https://www.complang.tuwien.ac.at/ulrich/iso-prolog/stc#21) | unbounded-integer resource exhaustion | The strict suite now prevents host `RangeError` leakage from oversized integer shifts/powers and reports `resource_error(memory)`, consistent with the Part 1 resource-error note and the STC correction proposal. The same principle is used when unbounded `functor/3` construction exhausts a finite host resource. |
|
|
22
|
+
| [#27](https://www.complang.tuwien.ac.at/ulrich/iso-prolog/stc#27)-[#29](https://www.complang.tuwien.ac.at/ulrich/iso-prolog/stc#29) | overlapping character/code/byte stream errors | Existing stream tests plus strict probes preserve argument validation before later stream-state errors where the published error clauses require it; the STC examples with an open alias produce the stated instantiation/type errors. |
|
|
20
23
|
| [#37](https://www.complang.tuwien.ac.at/ulrich/iso-prolog/stc#37) | `clause/2` variable identity | `stc/clause_variable_identity` verifies sharing between head and body is preserved. |
|
|
21
24
|
| [#39](https://www.complang.tuwien.ac.at/ulrich/iso-prolog/stc#39) | negative-number syntax | Covered extensively by the upstream-first WG17 syntax matrix; unary-minus read-back discrepancies found by that matrix were fixed in v1.3.27. |
|
|
22
25
|
| [#40](https://www.complang.tuwien.ac.at/ulrich/iso-prolog/stc#40) | inexact float representation | EyeProlog uses the host IEEE-754 binary64 value and requires written floats to read back to that same value. Input underflow is covered by `stc/float_underflow_input`. |
|
|
23
26
|
| [#42](https://www.complang.tuwien.ac.at/ulrich/iso-prolog/stc#42) | integer-to-float conversion for float functions | `stc/integer_to_float_evaluable` verifies an integer expression is accepted by `sin/1` and produces a float. |
|
|
24
|
-
| [#44](https://www.complang.tuwien.ac.at/ulrich/iso-prolog/stc#44) | `char_code/2` error classification |
|
|
27
|
+
| [#44](https://www.complang.tuwien.ac.at/ulrich/iso-prolog/stc#44) | `char_code/2` error classification | Strict coverage distinguishes `type_error(integer,Code)` for a non-integer code from `representation_error(character_code)` for an integer outside the character-code set. |
|
|
25
28
|
| [#49](https://www.complang.tuwien.ac.at/ulrich/iso-prolog/stc#49) | `read_term/3` and EOF | Covered by strict reader/conformance tests and the interactive-read regressions. |
|
|
26
|
-
| [#50](https://www.complang.tuwien.ac.at/ulrich/iso-prolog/stc#50) | mixed integer/float arithmetic comparison |
|
|
29
|
+
| [#50](https://www.complang.tuwien.ac.at/ulrich/iso-prolog/stc#50) | mixed integer/float arithmetic comparison | The STC-facing normal-profile case requires exact cross-type ordering and `max/2`/`min/2` use the same comparison. `--iso-strict` deliberately retains the published Part 1 integer-to-float comparison rule; the draft case is not silently substituted for that normative baseline. |
|
|
27
30
|
| [#55](https://www.complang.tuwien.ac.at/ulrich/iso-prolog/stc#55) | integer rounding function | Existing flag conformance verifies `integer_rounding_function = toward_zero`. |
|
|
31
|
+
| [#56](https://www.complang.tuwien.ac.at/ulrich/iso-prolog/stc#56) | protect `(:-)/1` and `(:-)/2` from database modification | **Found a gap during the #65 audit.** Strict database operations now treat both functors as static/private for `assert*`, `retract*`, `abolish/1`, declarations, and `clause/2`, while ordinary calls still follow the separate procedure-existence behavior described by the STC item. |
|
|
28
32
|
| [#58](https://www.complang.tuwien.ac.at/ulrich/iso-prolog/stc#58) | `set_prolog_flag/2` instantiation error | Existing strict/error coverage requires an instantiation error when a required flag value is a variable. |
|
|
29
33
|
| [#67](https://www.complang.tuwien.ac.at/ulrich/iso-prolog/stc#67) | `bagof/3` answer-order example | `stc/bagof_answer_order` verifies the proposed clarifying example produces `[2,1]`. |
|
|
30
34
|
| [#73](https://www.complang.tuwien.ac.at/ulrich/iso-prolog/stc#73) | float-reading limits discussed from issue #54 | Positive/negative literal and `number_chars/2` overflow are kept as explicit draft cases; underflow is tested separately. See the note below. |
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
answer(7, red, caught(eyeprolog), first, caught(eyeprolog)).
|
|
2
2
|
answer(7, red, caught(eyeprolog), second, caught(eyeprolog)).
|
|
3
|
-
flags(off, on, [pair(bounded, false), pair(integer_rounding_function, toward_zero), pair(char_conversion, on), pair(debug, off), pair(max_arity,
|
|
3
|
+
flags(off, on, [pair(bounded, false), pair(integer_rounding_function, toward_zero), pair(char_conversion, on), pair(debug, off), pair(max_arity, unbounded), pair(unknown, fail), pair(double_quotes, chars), pair(occurs_check, true)]).
|
package/test/run-iso-strict.mjs
CHANGED
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
Env,
|
|
9
9
|
createStrictIsoRegistry,
|
|
10
10
|
parseGoalText,
|
|
11
|
+
parseProgramText,
|
|
11
12
|
run,
|
|
12
13
|
} from '../src/index.js';
|
|
13
14
|
import { TestReporter, isMainModule, runStandalone } from './test-style.mjs';
|
|
@@ -55,7 +56,7 @@ export function runIsoStrict(reporter = new TestReporter()) {
|
|
|
55
56
|
'current_prolog_flag(integer_rounding_function,toward_zero)',
|
|
56
57
|
'current_prolog_flag(char_conversion,on)',
|
|
57
58
|
'current_prolog_flag(debug,off)',
|
|
58
|
-
'current_prolog_flag(max_arity,
|
|
59
|
+
'current_prolog_flag(max_arity,unbounded)',
|
|
59
60
|
'current_prolog_flag(unknown,error)',
|
|
60
61
|
'current_prolog_flag(double_quotes,chars)',
|
|
61
62
|
]) equal(answers(goalText), 1, goalText);
|
|
@@ -71,7 +72,7 @@ export function runIsoStrict(reporter = new TestReporter()) {
|
|
|
71
72
|
'permission_error(modify, flag)', 'bounded valid-but-fixed value');
|
|
72
73
|
equal(capture(() => run('', { isoStrict: true, goal: 'set_prolog_flag(integer_rounding_function,down)' })).formal,
|
|
73
74
|
'permission_error(modify, flag)', 'rounding valid-but-fixed value');
|
|
74
|
-
equal(capture(() => run('', { isoStrict: true, goal: 'set_prolog_flag(max_arity,
|
|
75
|
+
equal(capture(() => run('', { isoStrict: true, goal: 'set_prolog_flag(max_arity,unbounded)' })).formal,
|
|
75
76
|
'permission_error(modify, flag)', 'max_arity valid-but-fixed value');
|
|
76
77
|
equal(capture(() => run('', { isoStrict: true, goal: 'set_prolog_flag(max_integer,unbounded)' })).formal,
|
|
77
78
|
'domain_error(flag_value)', 'max_integer has no value when unbounded');
|
|
@@ -81,13 +82,21 @@ export function runIsoStrict(reporter = new TestReporter()) {
|
|
|
81
82
|
'domain_error(prolog_flag)', 'unsupported flag');
|
|
82
83
|
});
|
|
83
84
|
|
|
84
|
-
reporter.test('keeps max_arity
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
equal(
|
|
90
|
-
|
|
85
|
+
reporter.test('keeps max_arity unbounded for compound terms', () => {
|
|
86
|
+
const program = Program.parse('', { isoStrict: true });
|
|
87
|
+
const solver = new Solver(program, { isoStrict: true });
|
|
88
|
+
const answers = (text) => [...solver.solve([parseGoalText(text, { isoStrict: true })], new Env(), 0)].length;
|
|
89
|
+
equal(answers('current_prolog_flag(max_arity,unbounded)'), 1, 'unbounded flag value');
|
|
90
|
+
equal(answers('functor(T,foo,65536),arg(65536,T,z)'), 1, 'functor beyond former 65535 ceiling');
|
|
91
|
+
|
|
92
|
+
const source = `wide(${Array.from({ length: 65536 }, () => 'a').join(',')}).`;
|
|
93
|
+
const clauses = parseProgramText(source, { isoStrict: true, sourceMetadata: true });
|
|
94
|
+
equal(clauses[0]?.head?.arity, 65536, 'source term beyond former 65535 ceiling');
|
|
95
|
+
|
|
96
|
+
// A very large predicate indicator that names no procedure must not be
|
|
97
|
+
// rounded through JavaScript Number or misreported as max_arity.
|
|
98
|
+
equal(run('', { isoStrict: true, goal: 'abolish(foo/9007199254740993)' }).stats.completed_goal_lists,
|
|
99
|
+
1, 'large nonexistent predicate indicator');
|
|
91
100
|
});
|
|
92
101
|
|
|
93
102
|
reporter.test('preparation-time char_conversion affects later unquoted source only', () => {
|
|
@@ -315,11 +324,12 @@ export function runIsoStrict(reporter = new TestReporter()) {
|
|
|
315
324
|
'type_error(list)', '=../2 fixed non-list');
|
|
316
325
|
});
|
|
317
326
|
|
|
318
|
-
reporter.test('
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
327
|
+
reporter.test('keeps Corrigendum 2 call/N compatible with unbounded max_arity', () => {
|
|
328
|
+
// Corrigendum 2 prescribes representation_error(max_arity) only when the
|
|
329
|
+
// resulting closure exceeds a finite max_arity. With the selected
|
|
330
|
+
// `unbounded` value that conditional branch does not apply.
|
|
331
|
+
equal(run('', { isoStrict: true, goal: "call(=(x),x)" }).stdout,
|
|
332
|
+
'call(=(x), x).\n', 'call/2 closure expansion');
|
|
323
333
|
});
|
|
324
334
|
|
|
325
335
|
reporter.test('reports the complete List culprit for Corrigendum 2 atomic conversions', () => {
|
|
@@ -351,6 +361,35 @@ export function runIsoStrict(reporter = new TestReporter()) {
|
|
|
351
361
|
equal(program.operators.has('xfx\u0000?-'), false, 'xfx ?-');
|
|
352
362
|
});
|
|
353
363
|
|
|
364
|
+
reporter.test('pins applicable post-Corrigendum STC clarifications', () => {
|
|
365
|
+
equal(run('', { isoStrict: true, goal: 'integer(- /**/ 1)' }).stats.completed_goal_lists,
|
|
366
|
+
1, 'layout between minus and integer token');
|
|
367
|
+
|
|
368
|
+
const shared = run(
|
|
369
|
+
':- dynamic(a/1).\na(X) :- b(X).\n',
|
|
370
|
+
{ isoStrict: true, goal: 'clause(a(A),b(B)),A==B,A=ok' },
|
|
371
|
+
);
|
|
372
|
+
equal(shared.stats.completed_goal_lists, 1, 'clause/2 preserves head/body variable identity');
|
|
373
|
+
|
|
374
|
+
equal(capture(() => run('', { isoStrict: true, goal: 'char_code(_,c)' })).formal,
|
|
375
|
+
'type_error(integer)', 'char_code/2 non-integer code');
|
|
376
|
+
equal(capture(() => run('', { isoStrict: true, goal: 'set_prolog_flag(unknown,_)' })).formal,
|
|
377
|
+
'instantiation_error', 'set_prolog_flag/2 variable value');
|
|
378
|
+
equal(run('', {
|
|
379
|
+
isoStrict: true,
|
|
380
|
+
goal: 'read(T),T=end_of_file',
|
|
381
|
+
ioOptions: { input: '' },
|
|
382
|
+
}).stats.completed_goal_lists, 1, 'read/1 end_of_file');
|
|
383
|
+
includes(run('', {
|
|
384
|
+
isoStrict: true,
|
|
385
|
+
goal: 'bagof(X,(X=2;X=1),S),S=[2,1],X=ok',
|
|
386
|
+
}).stdout, '[2, 1]', 'bagof/3 preserves answer order');
|
|
387
|
+
|
|
388
|
+
Program.parse(':- op(500,xfx,foo).\na foo b.\n', { isoStrict: true });
|
|
389
|
+
const beforeDefinition = capture(() => Program.parse('a foo b.\n:- op(500,xfx,foo).\n', { isoStrict: true }));
|
|
390
|
+
includes(beforeDefinition.message, 'expected .', 'op/3 directive applies only to following text');
|
|
391
|
+
});
|
|
392
|
+
|
|
354
393
|
reporter.test('rejects EyeProlog module directives', () => {
|
|
355
394
|
const error = capture(() => Program.parse(':- use_module(library(lists)).\n', { isoStrict: true }));
|
|
356
395
|
includes(error.message, 'implementation-specific directive use_module/1', 'message');
|
|
@@ -400,6 +439,41 @@ export function runIsoStrict(reporter = new TestReporter()) {
|
|
|
400
439
|
'permission_error(access, private_procedure)', 'clause/2 conjunction access');
|
|
401
440
|
});
|
|
402
441
|
|
|
442
|
+
reporter.test('protects directive and rule functors from database modification per STC 56', () => {
|
|
443
|
+
const protectedGoals = [
|
|
444
|
+
"asserta(((':-'(a,b)):-true))",
|
|
445
|
+
"asserta(((':-'(b)):-true))",
|
|
446
|
+
"assertz(((':-'(a,b)):-true))",
|
|
447
|
+
"retract((':-'(a,b):-true))",
|
|
448
|
+
"retractall((':-'(a,b):-true))",
|
|
449
|
+
"abolish('/'(':-',2))",
|
|
450
|
+
"abolish('/'(':-',1))",
|
|
451
|
+
];
|
|
452
|
+
for (const goal of protectedGoals) {
|
|
453
|
+
equal(capture(() => run('', { isoStrict: true, goal })).formal,
|
|
454
|
+
'permission_error(modify, static_procedure)', goal);
|
|
455
|
+
}
|
|
456
|
+
equal(capture(() => run('', { isoStrict: true, goal: "clause(':-'(a,b),_)" })).formal,
|
|
457
|
+
'permission_error(access, private_procedure)', 'clause/2 (:-)/2 access');
|
|
458
|
+
equal(capture(() => run('', { isoStrict: true, goal: "clause(':-'(b),_)" })).formal,
|
|
459
|
+
'permission_error(access, private_procedure)', 'clause/2 (:-)/1 access');
|
|
460
|
+
equal(capture(() => run('', { isoStrict: true, goal: "call(':-'(a,b))" })).formal,
|
|
461
|
+
'existence_error(procedure)', 'STC 56 keeps calls distinct from modification');
|
|
462
|
+
equal(capture(() => Program.parse(":- dynamic('/'(':-',2)).\n", { isoStrict: true })).formal,
|
|
463
|
+
'permission_error(modify, static_procedure)', 'preparation-time (:-)/2 declaration protection');
|
|
464
|
+
});
|
|
465
|
+
|
|
466
|
+
reporter.test('reports finite host exhaustion without imposing ISO representation bounds', () => {
|
|
467
|
+
equal(capture(() => run('', { isoStrict: true, goal: 'functor(T,f,4294967296)' })).formal,
|
|
468
|
+
'resource_error(memory)', 'unbounded max_arity host array exhaustion');
|
|
469
|
+
equal(capture(() => run('', { isoStrict: true, goal: 'X is 1 << 4294967296' })).formal,
|
|
470
|
+
'resource_error(memory)', 'unbounded integer shift host exhaustion');
|
|
471
|
+
equal(capture(() => run('', { isoStrict: true, goal: 'X is 2 ^ 4294967296' })).formal,
|
|
472
|
+
'resource_error(memory)', 'unbounded integer power host exhaustion');
|
|
473
|
+
equal(run('', { isoStrict: true, goal: 'current_prolog_flag(max_arity,unbounded)' }).stats.completed_goal_lists,
|
|
474
|
+
1, 'resource handling does not reintroduce a finite max_arity');
|
|
475
|
+
});
|
|
476
|
+
|
|
403
477
|
reporter.test('covers ISO database predicate errors and empty-procedure lifetime', () => {
|
|
404
478
|
const errors = [
|
|
405
479
|
['current_predicate(4)', '', 'type_error(predicate_indicator)'],
|
package/the-art-of-eyeprolog.md
CHANGED
|
@@ -6004,7 +6004,7 @@ silently changing a static program.
|
|
|
6004
6004
|
| `debug` | `off` | `on`, `off` | yes |
|
|
6005
6005
|
| `max_integer` | no current value because `bounded=false` | not applicable | no |
|
|
6006
6006
|
| `min_integer` | no current value because `bounded=false` | not applicable | no |
|
|
6007
|
-
| `max_arity` | `
|
|
6007
|
+
| `max_arity` | `unbounded` | `unbounded` | no |
|
|
6008
6008
|
| `unknown` | `error` | `error`, `fail`, `warning` | yes |
|
|
6009
6009
|
| `double_quotes` | `chars` | `chars`, `codes`, `atom` | yes |
|
|
6010
6010
|
| `occurs_check` | `true` | `true`, `error` | yes |
|