Skip to content

Commit

Permalink
Fix handling of absent values when removing unused code. Fixes #864.
Browse files Browse the repository at this point in the history
  • Loading branch information
guidotack committed Nov 7, 2024
1 parent 76ab70a commit a2b3761
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Bug fixes:
- Fix incorrect typing of arrays in assignment generators (:bugref:`858`).
- Fix bug in flattening of implication with optional right hand side.
- Fix flattening of ``exists`` and ``forall`` with optional arguments.
- Fix handling of absent values when removing unused code (:bugref:`864`).

.. _v2.8.7:

Expand Down
3 changes: 3 additions & 0 deletions include/minizinc/optimize.hh
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ public:
} /// TODO: test if id's domain is a superset of the right hand side
/// this currently only tests for equality, and for Boolean domains
if (Id* ident = Expression::dynamicCast<Id>(vd->e())) {
if (Expression::equal(ident, Constants().absent)) {
return false;
}
if (Expression::equal(ident->decl()->ti()->domain(), vd->ti()->domain())) {
return true;
}
Expand Down
7 changes: 7 additions & 0 deletions tests/spec/unit/regression/test_bug_864.mzn
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/***
!Test
expected: !Result
status: SATISFIED
***/
array[1..2] of var opt 0..10: y;
constraint forall (j in 1..2) (y[j] == if j == 1 then <> else let { var 0..10: x} in x endif);

0 comments on commit a2b3761

Please sign in to comment.