check for unbound calls (#154)

This commit is contained in:
Vitor Santos Costa 2009-12-03 09:08:06 +00:00
parent f08d8b4b04
commit 2d6934178b

View File

@ -66,9 +66,21 @@ setup_call_cleanup(Setup, Goal, Cleanup) :-
setup_call_catcher_cleanup(Setup, Goal, Catcher, Cleanup) :-
yap_hacks:disable_interrupts,
'$check_goal_for_setup_call_cleanup'(Setup, setup_call_catcher_cleanup(Setup, Goal, Catcher, Cleanup)),
'$do_setup'(Setup),
'$check_goal_for_setup_call_cleanup'(Cleanup, setup_call_catcher_cleanup(Setup, Goal, Catcher, Cleanup)),
'$safe_call_cleanup'(Goal,Cleanup,Catcher,Exception).
'$check_goal_for_setup_call_cleanup'(Goal, G) :-
strip_module(Goal, _, MG),
(
var(MG)
->
'$do_error'(instantiation_error,G)
;
true
).
% this is simple, do nothing
'$do_setup'(A:true) :- atom(A), !.
% this is tricky: please don't forget that interrupts are disabled at this point