From 2d6934178bbd5af1fdb0135eb3f8e2d92f87cb01 Mon Sep 17 00:00:00 2001 From: Vitor Santos Costa Date: Thu, 3 Dec 2009 09:08:06 +0000 Subject: [PATCH] check for unbound calls (#154) --- pl/control.yap | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/pl/control.yap b/pl/control.yap index d2708b234..f753cdaec 100644 --- a/pl/control.yap +++ b/pl/control.yap @@ -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