Skip to content

Commit

Permalink
Automatically coerce arrays constructed using ++ to any enum index se…
Browse files Browse the repository at this point in the history
…t (in addition to array literals and comprehensions)
  • Loading branch information
guidotack committed Dec 14, 2016
1 parent b274b59 commit 50f3703
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ Changes:
- Add missing min/max functions for set variables. Can be redefined to solver
builtins using the new redefinitions-2.1.1.mzn library file.
- Add support for option type expressions as objective functions.
- Automatically coerce arrays constructed using ++ to any enum index set
(in addition to array literals and comprehensions).

Bug fixes:
- Include cmath header to fix compilation issues with some compilers. Fixes #125.
Expand Down
4 changes: 3 additions & 1 deletion lib/typecheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1105,7 +1105,9 @@ namespace MiniZinc {
if (vd.e()) {
Type vdt = vd.ti()->type();
Type vet = vd.e()->type();
if (vdt.enumId() != 0 && vdt.dim() > 0 && (vd.e()->isa<ArrayLit>() || vd.e()->isa<Comprehension>())) {
if (vdt.enumId() != 0 && vdt.dim() > 0 &&
(vd.e()->isa<ArrayLit>() || vd.e()->isa<Comprehension>() ||
(vd.e()->isa<BinOp>() && vd.e()->cast<BinOp>()->op()==BOT_PLUSPLUS))) {
// Special case: index sets of array literals and comprehensions automatically
// coerce to any enum index set
const std::vector<unsigned int>& enumIds = _env.getArrayEnum(vdt.enumId());
Expand Down

0 comments on commit 50f3703

Please sign in to comment.