From 756bba9bc50ccc3d7d0e8d7be3bd00623dc89251 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADtor=20Santos=20Costa?= Date: Thu, 22 Mar 2012 22:09:08 +0000 Subject: [PATCH] fix by UN to do type checking on sort. --- pl/sort.yap | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/pl/sort.yap b/pl/sort.yap index cbbc7ca1e..5b09c4379 100644 --- a/pl/sort.yap +++ b/pl/sort.yap @@ -54,6 +54,27 @@ length(L, M) :- M is N + 1, NL = [_|L], '$$_length2'(L, O, M) ). sort(L,O) :- + '$skip_list'(L,NL,RL), + ( RL == [] -> true ; + var(RL) -> '$do_error'(instantiation_error,sort(L,O)) ; + '$do_error'(type_error(list,L),sort(L,O)) + ), + ( + nonvar(O) + -> + ( + O == [] + -> + L == [] + ; + '$skip_list'(O,NO,RO), + ( RO == [] -> NO =< NL ; + var(RO) -> NO =< NL ; + '$do_error'(type_error(list,O),sort(L,O)) + ) + ) + ; true + ), '$sort'(L,O). msort(L,O) :-