add correct error sources to bagof/3, setof/3, findall/4
This commit is contained in:
@@ -363,14 +363,14 @@ throw(Ball) :- '$set_ball'(Ball), '$unwind_stack'.
|
||||
|
||||
truncate_lh_to(LhLength) :- '$truncate_lh_to'(LhLength).
|
||||
|
||||
check_for_compat_list(L) :-
|
||||
check_for_compat_list(L, PI) :-
|
||||
'$skip_max_list'(_, -1, L, R),
|
||||
( nonvar(R), R \== [], throw(error(type_error(list, L), findall/3))
|
||||
( nonvar(R), R \== [], throw(error(type_error(list, L), PI))
|
||||
; true
|
||||
).
|
||||
|
||||
findall(Template, Goal, Solutions) :-
|
||||
check_for_compat_list(Solutions),
|
||||
check_for_compat_list(Solutions, findall/3),
|
||||
'$lh_length'(LhLength),
|
||||
'$call_with_default_policy'(catch('$iterate_find_all'(Template, Goal, Solutions, LhLength),
|
||||
Error,
|
||||
@@ -387,8 +387,8 @@ findall(Template, Goal, Solutions) :-
|
||||
|
||||
|
||||
findall(Template, Goal, Solutions0, Solutions1) :-
|
||||
check_for_compat_list(Solutions0),
|
||||
check_for_compat_list(Solutions1),
|
||||
check_for_compat_list(Solutions0, findall/4),
|
||||
check_for_compat_list(Solutions1, findall/4),
|
||||
'$lh_length'(LhLength),
|
||||
'$call_with_default_policy'(catch('$iterate_find_all_diff'(Template, Goal, Solutions0,
|
||||
Solutions1, LhLength),
|
||||
@@ -418,7 +418,7 @@ iterate_variants([_|GroupSolutions], Ws, Solution) :-
|
||||
iterate_variants(GroupSolutions, Ws, Solution).
|
||||
|
||||
bagof(Template, Goal, Solution) :-
|
||||
check_for_compat_list(Solution),
|
||||
check_for_compat_list(Solution, bagof/3),
|
||||
term_variables(Template, TemplateVars0),
|
||||
term_variables(Goal, GoalVars0),
|
||||
sort(TemplateVars0, TemplateVars),
|
||||
@@ -435,6 +435,7 @@ iterate_variants_and_sort([_|GroupSolutions], Ws, Solution) :-
|
||||
iterate_variants_and_sort(GroupSolutions, Ws, Solution).
|
||||
|
||||
setof(Template, Goal, Solution) :-
|
||||
check_for_compat_list(Solution, setof/3),
|
||||
term_variables(Template, TemplateVars0),
|
||||
term_variables(Goal, GoalVars0),
|
||||
sort(TemplateVars0, TemplateVars),
|
||||
|
||||
Reference in New Issue
Block a user