Avoid dif/1 attribute with empty list

Closes #1956
This commit is contained in:
bakaq
2023-09-21 14:00:37 -03:00
parent cac52c0537
commit cb79e83510
2 changed files with 11 additions and 1 deletions

View File

@@ -35,7 +35,10 @@ vars_remove_goal([], _).
vars_remove_goal([Var|Vars], Goal0) :-
get_atts(Var, +dif(Goals0)),
remove_goal(Goals0, Goal0, Goals),
put_atts(Var, +dif(Goals)),
( Goals = [] ->
put_atts(Var, -dif(_))
; put_atts(Var, +dif(Goals))
),
vars_remove_goal(Vars, Goal0).
reinforce_goal(Goal0, Goal) :-

View File

@@ -189,6 +189,13 @@ test("dif#12 but with multiple variables in the residuals",(
Res = []
)).
% https://github.com/mthom/scryer-prolog/issues/1956
test("scryer-prolog#1956",(
call_residue_vars((dif(a-a,X-_),X=b), Res),
X == b,
Res = []
)).
main :-
findall(test(Name, Goal), test(Name, Goal), Tests),
run_tests(Tests, Failed),