]> Repositorios git - scryer-prolog.git/commitdiff
Avoid dif/1 attribute with empty list
authorbakaq <[email protected]>
Thu, 21 Sep 2023 17:00:37 +0000 (14:00 -0300)
committerbakaq <[email protected]>
Thu, 21 Sep 2023 17:00:37 +0000 (14:00 -0300)
Closes #1956

src/lib/dif.pl
src/tests/dif.pl

index 4fe35b800c872fb49dbc0ae180ea5ebd5056c513..fedb320cccd1f095e97fe208050a364ca529039c 100644 (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) :-
index 752458b558b2fa388a4f63b13728f5fa401b5162..bb1c76d6934832c45e5bce123bbb516a13b7dbfe 100644 (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),