Skip to content

Commit

Permalink
fix dif:vars_remove_goal/2 (#2175), untabify forms.rs to appease form…
Browse files Browse the repository at this point in the history
…at check
  • Loading branch information
mthom committed Nov 20, 2023
1 parent 8d9a759 commit 14d7a9b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
10 changes: 5 additions & 5 deletions src/forms.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
12 changes: 7 additions & 5 deletions src/lib/dif.pl
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,13 @@

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).

Expand Down
7 changes: 7 additions & 0 deletions src/tests/dif.pl
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,13 @@
\+ 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),
Expand Down

0 comments on commit 14d7a9b

Please sign in to comment.