]> Repositorios git - scryer-prolog.git/commitdiff
stop unifying ! to free variables in control_functor/1 (#887)
authorMark Thom <[email protected]>
Wed, 24 Mar 2021 21:05:59 +0000 (15:05 -0600)
committerMark Thom <[email protected]>
Wed, 24 Mar 2021 21:05:59 +0000 (15:05 -0600)
src/lib/builtins.pl
src/lib/iso_ext.pl
src/toplevel.pl

index 16d842bbbfa567c3825cad8edd3ebe94445d85b8..ad86d21979327c0d831240e760b368979c73fcec 100644 (file)
@@ -255,8 +255,8 @@ call_or_cut(G, B, ErrorPI) :-
 
 :- non_counted_backtracking control_functor/1.
 
-control_functor(_:G) :- control_functor(G).
-control_functor(call(_:!)).
+control_functor(_:G) :- nonvar(G), control_functor(G).
+control_functor(call(_:C)) :- C == !.
 control_functor(!).
 control_functor((_,_)).
 control_functor((_;_)).
@@ -577,9 +577,6 @@ catch(G,C,R) :-
     '$get_current_block'(Bb),
     '$call_with_default_policy'(catch(G,C,R,Bb)).
 
-
-:- meta_predicate catch(0, ?, 0, +).
-
 :- non_counted_backtracking catch/4.
 catch(G,C,R,Bb) :-
     '$install_new_block'(NBb),
@@ -599,8 +596,6 @@ end_block(Bb, NBb) :-
     '$reset_block'(NBb),
     '$fail'.
 
-:- meta_predicate handle_ball(?, ?, 0).
-
 :- non_counted_backtracking handle_ball/3.
 handle_ball(C, C, R) :-
     !,
@@ -612,8 +607,6 @@ handle_ball(_, _, _) :-
 throw(Ball) :- '$set_ball'(Ball), '$unwind_stack'.
 
 
-% :- meta_predicate '$iterate_find_all'(?, 0, ?, ?).
-
 :- non_counted_backtracking '$iterate_find_all'/4.
 '$iterate_find_all'(Template, Goal, _, LhOffset) :-
     call(Goal),
index 7d580497a2411e73941bde1b2578b3afb7a1adc4..4d064193c217719a70d6a6c46546fc276c9538d5 100644 (file)
                     variant/2,
                     copy_term_nat/2]).
 
-:- use_module(library(error), [can_be/2, domain_error/3, type_error/3]).
+:- use_module(library(error), [can_be/2,
+                               domain_error/3,
+                               instantiation_error/1,
+                               type_error/3]).
 
 
 :- meta_predicate call_cleanup(0, 0).
 
 :- meta_predicate setup_call_cleanup(0, 0, 0).
 
+:- meta_predicate forall(0, 0).
 
 forall(Generate, Test) :-
     \+ (Generate, \+ Test).
@@ -61,20 +65,24 @@ setup_call_cleanup(S, G, C) :-
     call(S),
     '$set_cp_by_default'(B),
     '$get_current_block'(Bb),
-    (  '$call_with_default_policy'(var(C)) ->
-       throw(error(instantiation_error, setup_call_cleanup/3))
+    (  C = _:CC,
+       '$call_with_default_policy'(var(CC)) ->
+       instantiation_error(setup_call_cleanup/3)
     ;  '$call_with_default_policy'(scc_helper(C, G, Bb))
     ).
 
 :- non_counted_backtracking scc_helper/3.
 scc_helper(C, G, Bb) :-
-    '$get_cp'(Cp), '$install_scc_cleaner'(C, NBb), call(G),
+    '$get_cp'(Cp),
+    '$install_scc_cleaner'(C, NBb),
+    call(G),
     ( '$check_cp'(Cp) ->
       '$reset_block'(Bb),
       '$call_with_default_policy'(run_cleaners_without_handling(Cp))
     ; '$call_with_default_policy'(true)
     ; '$reset_block'(NBb),
-      '$fail').
+      '$fail'
+    ).
 scc_helper(_, _, Bb) :-
     '$reset_block'(Bb),
     '$get_ball'(Ball),
index a41af81940c3e3fc48e5511e45a62a1f859b2757..0ddec4314234ac8df8d703045997e4b2d36720bf 100644 (file)
@@ -149,10 +149,9 @@ instruction_match(Term, VarList) :-
              ;
              submit_query_and_print_results(consult(Item), [])
              )
-       ;
-          catch(type_error(atom, Item, repl/0),
-                    E,
-                    print_exception_with_check(E))
+       ;  catch(type_error(atom, Item, repl/0),
+                       E,
+                       print_exception_with_check(E))
        )
     ;  Term = end_of_file ->
        halt
@@ -167,15 +166,12 @@ submit_query_and_print_results_(Term, VarList) :-
     write_eqs_and_read_input(B, VarList),
     !.
 submit_query_and_print_results_(_, _) :-
-    %  clear attribute goal lists, which may be populated by
-    %  copy_term/3 prior to failure.
     write('false.'),
     nl.
 
 
 submit_query_and_print_results(Term0, VarList) :-
     expand_goal(call(Term0), user, call(Term)),
-    !,
     setup_call_cleanup(bb_put('$first_answer', true),
                        submit_query_and_print_results_(Term, VarList),
                        bb_put('$first_answer', false)).