]> Repositorios git - scryer-prolog.git/commitdiff
fix dif:vars_remove_goal/2 (#2175), untabify forms.rs to appease format check
authorMark <[email protected]>
Mon, 20 Nov 2023 20:40:58 +0000 (13:40 -0700)
committerMark <[email protected]>
Mon, 20 Nov 2023 21:21:18 +0000 (14:21 -0700)
src/forms.rs
src/lib/dif.pl
src/tests/dif.pl

index 3a2b743f2e043b62fcb2514310500c43d7741f73..d18d41f1539a171e8885c1b8fc7fefd8ed15ff40 100644 (file)
@@ -744,11 +744,11 @@ impl Number {
             Number::Float(f) => Number::Float(OrderedFloat(f.signum())),
             _ => {
                 if self.is_positive() {
-                   if self.is_zero() {
-                       Number::Fixnum(Fixnum::build_with(0))
-                   } else {
-                       Number::Fixnum(Fixnum::build_with(1))
-                   }
+                    if self.is_zero() {
+                        Number::Fixnum(Fixnum::build_with(0))
+                    } else {
+                        Number::Fixnum(Fixnum::build_with(1))
+                    }
                 } else if self.is_negative() {
                     Number::Fixnum(Fixnum::build_with(-1))
                 } else {
index 8efb42710c0fb8fe6493b6c5167990ba9a58ed66..c344e1d750b3189931f12f3f1d8f13f62d07c814 100644 (file)
@@ -33,11 +33,13 @@ remove_goal([G0|G0s], Goal0, Goals) :-
 
 vars_remove_goal([], _).
 vars_remove_goal([Var|Vars], Goal0) :-
-    get_atts(Var, +dif(Goals0)),
-    remove_goal(Goals0, Goal0, Goals),
-    (   Goals = [] ->
-        put_atts(Var, -dif(_))
-    ;   put_atts(Var, +dif(Goals))
+    (  get_atts(Var, +dif(Goals0)) ->
+       remove_goal(Goals0, Goal0, Goals),
+       (   Goals = [] ->
+           put_atts(Var, -dif(_))
+       ;   put_atts(Var, +dif(Goals))
+       )
+    ;  true
     ),
     vars_remove_goal(Vars, Goal0).
 
index 752f14054610bd44d9bb7c56707f74d3cb13f8a6..f08360074389af2b5e6258b7863b7a2250d027b0 100644 (file)
@@ -207,6 +207,13 @@ test("scryer-prolog#2056",(
     \+ E=[]
 )).
 
+% https://github.com/mthom/scryer-prolog/issues/2175
+test("scryer-prolog#2175",(
+    dif(A,B),
+    A=_C*[],
+    A=[]*D*B,D=[]
+)).
+
 main :-
     findall(test(Name, Goal), test(Name, Goal), Tests),
     run_tests(Tests, Failed),