Skip to content

Commit

Permalink
Mark nvalue function as ::promise_total
Browse files Browse the repository at this point in the history
  • Loading branch information
cyderize committed Apr 20, 2023
1 parent f05edc4 commit 165db79
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ Bug fixes:
(:bugref:`679`).
- Fix common subexpression elimination for expressions used in incompatible
contexts (:bugref:`666`).
- Add missing ``::promise_total`` to functional version of ``nvalue``.

Changes in the IDE:
^^^^^^^^^^^^^^^^^^^
Expand Down
2 changes: 1 addition & 1 deletion share/minizinc/std/nvalue_fn.mzn
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ include "nvalue.mzn";
/** @group globals.alldifferent
Returns the number of distinct values in \a x.
*/
function var int: nvalue(array[$X] of var int: x) =
function var int: nvalue(array[$X] of var int: x) :: promise_total =
let { var 0..length(x): n::is_defined_var; constraint nvalue(n,x)::defines_var(n); } in n;
12 changes: 12 additions & 0 deletions tests/spec/unit/globals/nvalue/nvalue_total.mzn
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/***
!Test
solvers: [gecode]
expected: !Result
solution: !Solution
l1: 0
***/

include "nvalue_fn.mzn";

array[1..10] of var 0..10: X;
int: l1 :: output = lb(nvalue(X));

0 comments on commit 165db79

Please sign in to comment.