From 1e5bb2d3dab350483d151157e528f3c7abe6c3bd Mon Sep 17 00:00:00 2001 From: Mark Date: Mon, 20 Nov 2023 13:40:58 -0700 Subject: [PATCH] fix dif:vars_remove_goal/2 (#2175), untabify forms.rs to appease format check --- src/forms.rs | 10 +++++----- src/lib/dif.pl | 12 +++++++----- src/tests/dif.pl | 7 +++++++ 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/src/forms.rs b/src/forms.rs index 3a2b743f..d18d41f1 100644 --- a/src/forms.rs +++ b/src/forms.rs @@ -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 { diff --git a/src/lib/dif.pl b/src/lib/dif.pl index 8efb4271..c344e1d7 100644 --- a/src/lib/dif.pl +++ b/src/lib/dif.pl @@ -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). diff --git a/src/tests/dif.pl b/src/tests/dif.pl index 752f1405..f0836007 100644 --- a/src/tests/dif.pl +++ b/src/tests/dif.pl @@ -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), -- 2.54.0