From 07dd2b279ea6fb50e89a7b42b4638fbe3bc642e0 Mon Sep 17 00:00:00 2001 From: Paulo Moura <> Date: Sun, 9 May 2021 12:42:51 +0100 Subject: [PATCH] Fix throw/1 control construct to throw an instantiation error when the argument is not bound --- src/lib/builtins.pl | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/lib/builtins.pl b/src/lib/builtins.pl index 502827b6..bd11ac16 100644 --- a/src/lib/builtins.pl +++ b/src/lib/builtins.pl @@ -615,8 +615,12 @@ handle_ball(C, C, R) :- handle_ball(_, _, _) :- '$unwind_stack'. -throw(Ball) :- '$set_ball'(Ball), '$unwind_stack'. - +throw(Ball) :- + ( var(Ball) -> + '$set_ball'(error(instantiation_error,throw/1)) + ; '$set_ball'(Ball) + ), + '$unwind_stack'. :- non_counted_backtracking '$iterate_find_all'/4. '$iterate_find_all'(Template, Goal, _, LhOffset) :- -- 2.54.0