Merge pull request #965 from pmoura/fix_current_predicate_error_checking

Fix current_predicate/1 predicate error checking
This commit is contained in:
Mark Thom
2021-05-16 23:37:20 -06:00
committed by GitHub

View File

@@ -1083,8 +1083,17 @@ abolish(Pred) :-
current_predicate(Pred) :-
( nonvar(Pred), Pred \= _ / _
-> throw(error(type_error(predicate_indicator, Pred), current_predicate/1))
( var(Pred) ->
'$get_next_db_ref'(Ref, _),
'$iterate_db_refs'(Ref, Pred)
; Pred \= _/_ ->
throw(error(type_error(predicate_indicator, Pred), current_predicate/1))
; Pred = Name/Arity,
( nonvar(Name), \+ atom(Name)
; nonvar(Arity), \+ integer(Arity)
; integer(Arity), Arity < 0
) ->
throw(error(type_error(predicate_indicator, Pred), current_predicate/1))
; '$get_next_db_ref'(Ref, _),
'$iterate_db_refs'(Ref, Pred)
).