Skip to content

Commit

Permalink
Make sort functions return array of enum when input is array of enum.
Browse files Browse the repository at this point in the history
Fixes #853.
  • Loading branch information
guidotack committed Oct 30, 2024
1 parent 00116fa commit 58d2d79
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ Changes:
^^^^^^^^
- Add support for ``elseif`` in ``if then elseif endif`` expressions without an
`else` branch.
- Make ``sort`` functions return array of enum when input is array of
enum (:bugref:`853`).

Bug fixes:
^^^^^^^^^^
Expand Down
2 changes: 1 addition & 1 deletion share/minizinc/std/sort_fn.mzn
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ include "sort.mzn";
Return a multiset of values that is the same as the
multiset of values in \a x but in sorted order.
*/
function array[int] of var int: sort(array[int] of var int: x) ::promise_total =
function array[int] of var $$E: sort(array[int] of var $$E: x) ::promise_total =
let {
array[1..length(x)] of var lb_array(x)..ub_array(x): y ::is_defined_var;
constraint sort(x,y) ::defines_var(y);
Expand Down
2 changes: 1 addition & 1 deletion share/minizinc/std/stdlib/stdlib_sort.mzn
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ The sort is stable, i.e. if \a y[\p i] = \a y[\p j] with \p i < \p j, then
function array[$$E] of any $T: sort_by(array[$$E] of any $T: x, array[$$E] of float: y);

/** @group stdlib.sort Return values from array \a x sorted in non-decreasing order */
function array[$$E] of int: sort(array[$$E] of int: x);
function array[$$E] of $$F: sort(array[$$E] of $$F: x);
/** @group stdlib.sort Return values from array \a x sorted in non-decreasing order */
function array[$$E] of float: sort(array[$$E] of float: x);
/** @group stdlib.sort Return values from array \a x sorted in non-decreasing order */
Expand Down

0 comments on commit 58d2d79

Please sign in to comment.