eyeprolog 1.5.63 → 1.5.65
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
package/src/lib/si.pl
CHANGED
|
@@ -22,10 +22,10 @@ integer_si(I) :- ( var(I) -> throw(error(instantiation_error, [predicate-integer
|
|
|
22
22
|
atomic_si(A) :- ( var(A) -> throw(error(instantiation_error, [predicate-atomic_si/1])) ; atomic(A) ).
|
|
23
23
|
|
|
24
24
|
list_si(List) :- si__list(List).
|
|
25
|
+
si__list(Term) :-
|
|
26
|
+
var(Term), !, throw(error(instantiation_error, [predicate-list_si/1])).
|
|
25
27
|
si__list([]).
|
|
26
28
|
si__list([_|Tail]) :- !, si__list(Tail).
|
|
27
|
-
si__list(Term) :-
|
|
28
|
-
( var(Term) -> throw(error(instantiation_error, [predicate-list_si/1])) ; fail ).
|
|
29
29
|
|
|
30
30
|
character_si(C) :-
|
|
31
31
|
( var(C) -> throw(error(instantiation_error, [predicate-character_si/1]))
|
|
@@ -4545,6 +4545,22 @@ answer(Result) :- countdown(2048, Result), Result = 2048.
|
|
|
4545
4545
|
if (elapsed >= 20000) throw new Error(`20k wrapped calls took ${elapsed}ms`);
|
|
4546
4546
|
},
|
|
4547
4547
|
},
|
|
4548
|
+
{
|
|
4549
|
+
name: 'sufficient-instantiation list checks reject unknown tails without binding elements',
|
|
4550
|
+
run: () => {
|
|
4551
|
+
const input = ':- use_module(library(si)).\n%% goal: answer(X)\n' +
|
|
4552
|
+
'answer(ok) :- ' +
|
|
4553
|
+
'catch(list_si(X), error(instantiation_error,_), C1 = caught), C1 == caught, var(X), ' +
|
|
4554
|
+
'catch(list_si([a|T]), error(instantiation_error,_), C2 = caught), C2 == caught, var(T), ' +
|
|
4555
|
+
'catch(chars_si(Cs), error(instantiation_error,_), C3 = caught), C3 == caught, var(Cs), ' +
|
|
4556
|
+
'catch(chars_si([a|Tail]), error(instantiation_error,_), C4 = caught), C4 == caught, var(Tail), ' +
|
|
4557
|
+
'list_si([]), list_si([Element]), var(Element), chars_si([a,b]), ' +
|
|
4558
|
+
'\\+ list_si([a|bad]), \\+ chars_si([ab]).\n';
|
|
4559
|
+
const result = runCli(['-'], { input });
|
|
4560
|
+
assertEqual(result.status, 0, `exit status; stderr=${result.stderr}`);
|
|
4561
|
+
assertIncludes(result.stdout, 'answer(ok)', 'list checks preserve sufficient instantiation');
|
|
4562
|
+
},
|
|
4563
|
+
},
|
|
4548
4564
|
{
|
|
4549
4565
|
// Issue #100: compare_si/3 decides the standard order only when no
|
|
4550
4566
|
// instantiation could change it, and raises instantiation_error as
|