Skip to content

Commit

Permalink
Fix compilation of empty arrays with empty domains. Fixes #860.
Browse files Browse the repository at this point in the history
  • Loading branch information
guidotack committed Nov 7, 2024
1 parent a2b3761 commit cb4d558
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Bug fixes:
- 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`).
- Fix compilation of empty arrays with empty domains (:bugref:`860`).

.. _v2.8.7:

Expand Down
2 changes: 1 addition & 1 deletion lib/flatten/flatten_vardecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ EE flatten_vardecl(EnvI& env, const Ctx& ctx, Expression* e, VarDecl* r, VarDecl
TypeInst* ti = eval_typeinst(env, Ctx(), v);
bool isEmptyArray = false;
for (auto* nti : ti->ranges()) {
if (nti->domain() != nullptr &&
if (nti->domain() == nullptr ||
(Expression::isa<SetLit>(nti->domain()) && eval_intset(env, nti->domain())->empty())) {
isEmptyArray = true;
break;
Expand Down
6 changes: 6 additions & 0 deletions tests/spec/unit/regression/test_bug_860.mzn
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/***
!Test
expected: !Result
status: SATISFIED
***/
array[int] of var {}: Y = [];

0 comments on commit cb4d558

Please sign in to comment.