From: Paulo Moura <> Date: Sun, 9 May 2021 11:42:51 +0000 (+0100) Subject: Fix throw/1 control construct to throw an instantiation error when the argument is... X-Git-Tag: v0.9.0~77^2 X-Git-Url: https://git.sagredo.dev/?a=commitdiff_plain;h=07dd2b279ea6fb50e89a7b42b4638fbe3bc642e0;p=scryer-prolog.git Fix throw/1 control construct to throw an instantiation error when the argument is not bound --- 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) :-