]> Repositorios git - scryer-prolog.git/commitdiff
fix unexpected error in length/2 (#1303)
authorMark Thom <[email protected]>
Sat, 26 Feb 2022 18:07:38 +0000 (11:07 -0700)
committerMark Thom <[email protected]>
Sun, 27 Feb 2022 18:38:48 +0000 (11:38 -0700)
src/lib/lists.pl

index 22ee8d4be58a13247ecbfd7d79d7bb2bffebcb8c..964280d7eb9e7b6194f4917e6a6c0678a53779c5 100644 (file)
@@ -54,7 +54,7 @@ length(Xs0, N) :-
    '$skip_max_list'(M, N, Xs0,Xs),
    !,
    (  Xs == [] -> N = M
-   ;  nonvar(Xs) -> var(N), throw(error(resource_error(finite_memory),length/2))
+   ;  nonvar(Xs) -> var(N), Xs = [_|_], throw(error(resource_error(finite_memory),length/2))
    ;  nonvar(N) -> R is N-M, length_rundown(Xs, R)
    ;  N == Xs -> throw(error(resource_error(finite_memory),length/2))
    ;  length_addendum(Xs, N, M)